GrumPHP\Runner\TaskResult::createFailed PHP Метод

createFailed() публичный статический Метод

public static createFailed ( GrumPHP\Task\TaskInterface $task, GrumPHP\Task\Context\ContextInterface $context, string $message ) : TaskResult
$task GrumPHP\Task\TaskInterface
$context GrumPHP\Task\Context\ContextInterface
$message string
Результат TaskResult
    public static function createFailed(TaskInterface $task, ContextInterface $context, $message)
    {
        return new self(self::FAILED, $task, $context, $message);
    }

Usage Example

 /**
  * @param ContextInterface $context
  * @return TaskResult
  */
 public function run(ContextInterface $context)
 {
     $config = $this->getConfiguration();
     $files = $context->getFiles()->extensions($config['triggered_by']);
     if (0 === count($files)) {
         return TaskResult::createSkipped($this, $context);
     }
     if (is_file('./vendor/bin/fixbom')) {
         $fixCommand = './vendor/bin/fixbom';
     } elseif (is_file('./bin/fixbom')) {
         $fixCommand = './bin/fixbom';
     } else {
         $fixCommand = 'fixbom';
     }
     $shouldGetFixedLog = [];
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($files as $file) {
         $execFile = $file->getPathname();
         $debugLog[] = $execFile;
         if ($this->isFileWithBOM($execFile)) {
             $shouldGetFixedLog[] = $execFile . " has BOM and should be fixed";
             $fixCommand .= " '" . $execFile . "'";
         }
     }
     if (count($shouldGetFixedLog) > 0) {
         return TaskResult::createFailed($this, $context, implode(PHP_EOL, $shouldGetFixedLog) . PHP_EOL . "you can use this to fix them:" . PHP_EOL . $fixCommand);
     }
     return TaskResult::createPassed($this, $context);
 }
All Usage Examples Of GrumPHP\Runner\TaskResult::createFailed