Skip to content

Commit

Permalink
Merge pull request #1397 from hydephp/publications-command-cleanup
Browse files Browse the repository at this point in the history
Break down complex command class helper method
  • Loading branch information
caendesilva authored Oct 27, 2023
2 parents 528cd86 + 3c7d063 commit 6a413a8
Showing 1 changed file with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,15 @@ protected function displayResults(): void
if (empty($schemaErrors)) {
$this->line('<info> No top-level schema errors found</info>');
} else {
$this->line(sprintf(' <fg=red>Found %s top-level schema errors:</>', count($schemaErrors)));
foreach ($schemaErrors as $error) {
$this->line(sprintf(' <fg=red>%s</> <comment>%s</comment>', self::CROSS_MARK, $error));
}
$this->displayTopLevelSchemaErrors($schemaErrors);
}

$schemaFields = $errors['fields'];
if (empty(array_filter($schemaFields))) {
$this->line('<info> No field-level schema errors found</info>');
} else {
$this->newLine();
$this->line(sprintf(' <fg=red>Found errors in %s field definitions:</>', count($schemaFields)));
foreach ($schemaFields as $fieldNumber => $fieldErrors) {
$this->line(sprintf(' <fg=cyan>Field #%s:</>', $fieldNumber + 1));
foreach ($fieldErrors as $error) {
$this->line(sprintf(' <fg=red>%s</> <comment>%s</comment>', self::CROSS_MARK, $error));
}
}
$this->displayFieldDefinitionErrors($schemaFields);
}

if (next($this->results)) {
Expand All @@ -115,6 +106,25 @@ protected function displayResults(): void
}
}

protected function displayTopLevelSchemaErrors(array $schemaErrors): void
{
$this->line(sprintf(' <fg=red>Found %s top-level schema errors:</>', count($schemaErrors)));
foreach ($schemaErrors as $error) {
$this->line(sprintf(' <fg=red>%s</> <comment>%s</comment>', self::CROSS_MARK, $error));
}
}

protected function displayFieldDefinitionErrors(array $schemaFields): void
{
$this->line(sprintf(' <fg=red>Found errors in %s field definitions:</>', count($schemaFields)));
foreach ($schemaFields as $fieldNumber => $fieldErrors) {
$this->line(sprintf(' <fg=cyan>Field #%s:</>', $fieldNumber + 1));
foreach ($fieldErrors as $error) {
$this->line(sprintf(' <fg=red>%s</> <comment>%s</comment>', self::CROSS_MARK, $error));
}
}
}

protected function outputSummary($timeStart): void
{
$this->newLine();
Expand Down

0 comments on commit 6a413a8

Please sign in to comment.