/** * Display validation errors. * * @param Validator $validator The json-schema validator. * @param OutputInterface $output An OutputInterface instance. */ public static function displayErrors(Validator $validator, OutputInterface $output) { $table = new Table($output); $style = new TableStyle(); $style->setCellHeaderFormat('<error>%s</error>'); $style->setHorizontalBorderChar(' '); $style->setVerticalBorderChar(' '); $style->setCrossingChar(' '); $table->setHeaders(['Property', 'Error']); $table->setRows($validator->getErrors()); $table->setStyle($style); $table->render(); }
/** * @param string[] $rows * @param string[] $headers */ public function table(array $rows, array $headers = null) { $rows = array_map(function ($value) { if (!is_array($value)) { return $value; } $header = array_shift($value); array_unshift($value, sprintf('<fg=blue>%s</>', $header)); return $value; }, $rows); $style = new TableStyle(); $style->setVerticalBorderChar('<fg=blue>|</>'); $style->setHorizontalBorderChar('<fg=blue>-</>'); $style->setCrossingChar('<fg=blue>+</>'); $style->setCellHeaderFormat('%s'); $table = new Table($this); $table->setStyle($style); if ($headers) { $table->setHeaders($headers); } $table->setRows($rows); $table->render(); $this->newLine(); }