Skip to content

Commit

Permalink
Extract getting Neon
Browse files Browse the repository at this point in the history
  • Loading branch information
VasekPurchart committed Apr 25, 2022
1 parent af49905 commit 4e1f940
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/Command/ErrorFormatter/BaselineNeonErrorFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ public function formatErrors(
): int
{
if (!$analysisResult->hasErrors()) {
$output->writeRaw(Neon::encode([
'parameters' => [
'ignoreErrors' => [],
],
], Neon::BLOCK));
$output->writeRaw($this->getNeon([]));
return 0;
}

Expand Down Expand Up @@ -63,13 +59,22 @@ public function formatErrors(
}
}

$output->writeRaw(Neon::encode([
'parameters' => [
'ignoreErrors' => $errorsToOutput,
],
], Neon::BLOCK));
$output->writeRaw($this->getNeon($errorsToOutput));

return 1;
}

/**
* @param array<int, array{message: string, count: int, path: string}> $ignoreErrors
* @return string
*/
private function getNeon(array $ignoreErrors): string
{
return Neon::encode([
'parameters' => [
'ignoreErrors' => $ignoreErrors,
],
], Neon::BLOCK);
}

}

0 comments on commit 4e1f940

Please sign in to comment.