Skip to content

Commit 6a413a8

Browse files
authored
Merge pull request #1397 from hydephp/publications-command-cleanup
Break down complex command class helper method
2 parents 528cd86 + 3c7d063 commit 6a413a8

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

packages/publications/src/Commands/ValidatePublicationTypesCommand.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,15 @@ protected function displayResults(): void
8989
if (empty($schemaErrors)) {
9090
$this->line('<info> No top-level schema errors found</info>');
9191
} else {
92-
$this->line(sprintf(' <fg=red>Found %s top-level schema errors:</>', count($schemaErrors)));
93-
foreach ($schemaErrors as $error) {
94-
$this->line(sprintf(' <fg=red>%s</> <comment>%s</comment>', self::CROSS_MARK, $error));
95-
}
92+
$this->displayTopLevelSchemaErrors($schemaErrors);
9693
}
9794

9895
$schemaFields = $errors['fields'];
9996
if (empty(array_filter($schemaFields))) {
10097
$this->line('<info> No field-level schema errors found</info>');
10198
} else {
10299
$this->newLine();
103-
$this->line(sprintf(' <fg=red>Found errors in %s field definitions:</>', count($schemaFields)));
104-
foreach ($schemaFields as $fieldNumber => $fieldErrors) {
105-
$this->line(sprintf(' <fg=cyan>Field #%s:</>', $fieldNumber + 1));
106-
foreach ($fieldErrors as $error) {
107-
$this->line(sprintf(' <fg=red>%s</> <comment>%s</comment>', self::CROSS_MARK, $error));
108-
}
109-
}
100+
$this->displayFieldDefinitionErrors($schemaFields);
110101
}
111102

112103
if (next($this->results)) {
@@ -115,6 +106,25 @@ protected function displayResults(): void
115106
}
116107
}
117108

109+
protected function displayTopLevelSchemaErrors(array $schemaErrors): void
110+
{
111+
$this->line(sprintf(' <fg=red>Found %s top-level schema errors:</>', count($schemaErrors)));
112+
foreach ($schemaErrors as $error) {
113+
$this->line(sprintf(' <fg=red>%s</> <comment>%s</comment>', self::CROSS_MARK, $error));
114+
}
115+
}
116+
117+
protected function displayFieldDefinitionErrors(array $schemaFields): void
118+
{
119+
$this->line(sprintf(' <fg=red>Found errors in %s field definitions:</>', count($schemaFields)));
120+
foreach ($schemaFields as $fieldNumber => $fieldErrors) {
121+
$this->line(sprintf(' <fg=cyan>Field #%s:</>', $fieldNumber + 1));
122+
foreach ($fieldErrors as $error) {
123+
$this->line(sprintf(' <fg=red>%s</> <comment>%s</comment>', self::CROSS_MARK, $error));
124+
}
125+
}
126+
}
127+
118128
protected function outputSummary($timeStart): void
119129
{
120130
$this->newLine();

0 commit comments

Comments
 (0)