formatErrorMessage() public method

public formatErrorMessage ( array $messages, array $suggestions ) : string
$messages array
$suggestions array
return string
示例#1
0
 function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, PhpCsFixerFormatter $formatter)
 {
     $grumPHP->getTaskConfiguration('phpcsfixer')->willReturn(array());
     $formatter->format(Argument::any())->willReturn('');
     $formatter->formatSuggestion(Argument::any())->willReturn('');
     $formatter->formatErrorMessage(Argument::cetera())->willReturn('');
     $this->beConstructedWith($grumPHP, $processBuilder, $formatter);
 }
示例#2
0
 /**
  * @param ContextInterface           $context
  * @param ProcessArgumentsCollection $arguments
  * @param FilesCollection            $files
  *
  * @return TaskResult
  */
 protected function runOnChangedFiles(ContextInterface $context, ProcessArgumentsCollection $arguments, FilesCollection $files)
 {
     $hasErrors = false;
     $messages = [];
     $suggestions = [];
     foreach ($files as $file) {
         $fileArguments = new ProcessArgumentsCollection($arguments->getValues());
         $fileArguments->add($file);
         $processes[] = $this->processBuilder->buildProcess($fileArguments);
     }
     $this->processRunner->run($processes);
     foreach ($processes as $process) {
         if (!$process->isSuccessful()) {
             $hasErrors = true;
             $messages[] = $this->formatter->format($process);
             $suggestions[] = $this->formatter->formatSuggestion($process);
         }
     }
     if ($hasErrors) {
         $errorMessage = $this->formatter->formatErrorMessage($messages, $suggestions);
         return TaskResult::createFailed($this, $context, $errorMessage);
     }
     return TaskResult::createPassed($this, $context);
 }