Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break down complex command class helper method #1397

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading