PhpGitHooks\Module\Git\Service\PreCommitOutputWriter::setError PHP Method

setError() public method

public setError ( string $error ) : string
$error string
return string
    public function setError($error)
    {
        return sprintf("\n<error>%s</error>", trim($error));
    }

Usage Example

Esempio n. 1
0
 /**
  * @param array  $files
  * @param string $standard
  * @param string $errorMessage
  *
  * @throws PhpCsViolationException
  */
 public function execute(array $files, $standard, $errorMessage)
 {
     $outputMessage = new PreCommitOutputWriter(self::EXECUTE_MESSAGE);
     $this->output->write($outputMessage->getMessage());
     $errors = [];
     foreach ($files as $file) {
         $errors[] = $this->phpCsToolProcessor->process($file, $standard);
     }
     $errors = array_filter($errors);
     if (!empty($errors)) {
         $this->output->writeln($outputMessage->getFailMessage());
         $this->output->writeln($outputMessage->setError(implode('', $errors)));
         $this->output->writeln(BadJobLogoResponse::paint($errorMessage));
         throw new PhpCsViolationException();
     }
     $this->output->writeln($outputMessage->getSuccessfulMessage());
 }
All Usage Examples Of PhpGitHooks\Module\Git\Service\PreCommitOutputWriter::setError