/** * Registers hook stat. * * @param HookStat $stat */ public function registerHookStat(HookStat $stat) { if ($stat->isSuccessful()) { return; } $this->failedHookStats[] = $stat; }
/** * Prints hook stat. * * @param OutputPrinter $printer * @param HookStat $hookStat * @param string $style */ private function printHookStat(OutputPrinter $printer, HookStat $hookStat, $style) { $printer->writeln(sprintf(' {+%s}%s{-%s} {+comment}# %s{-comment}', $style, $hookStat->getName(), $style, $this->relativizePaths($hookStat->getPath()))); $pad = function ($line) { return ' ' . $line; }; if (null !== $hookStat->getStdOut()) { $padText = function ($line) { return ' │ ' . $line; }; $stdOutString = array_map($padText, explode("\n", $hookStat->getStdOut())); $printer->writeln(implode("\n", $stdOutString)); } if ($hookStat->getError()) { $exceptionString = implode("\n", array_map($pad, explode("\n", $hookStat->getError()))); $printer->writeln(sprintf('{+%s}%s{-%s}', $style, $exceptionString, $style)); } $printer->writeln(); }