fractalzombie /
frzb-request-mapper
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace FRZB\Component\RequestMapper\ExceptionFormatter\Formatter; |
||
| 6 | |||
| 7 | use Fp\Collections\ArrayList; |
||
| 8 | use FRZB\Component\DependencyInjection\Attribute\AsService; |
||
| 9 | use FRZB\Component\DependencyInjection\Attribute\AsTagged; |
||
| 10 | use FRZB\Component\RequestMapper\Data\ErrorContract; |
||
| 11 | use FRZB\Component\RequestMapper\Data\ErrorInterface as Error; |
||
| 12 | use FRZB\Component\RequestMapper\Data\FormattedError; |
||
| 13 | use FRZB\Component\RequestMapper\Exception\ValidationException; |
||
| 14 | use Symfony\Component\HttpFoundation\Response; |
||
| 15 | |||
| 16 | #[AsService, AsTagged(FormatterInterface::class)] |
||
| 17 | class ValidationFormatter implements FormatterInterface |
||
| 18 | 1 | { |
|
| 19 | public function __invoke(ValidationException $e): ErrorContract |
||
| 20 | 1 | { |
|
| 21 | 1 | return new FormattedError( |
|
| 22 | $e->getMessage(), |
||
| 23 | 1 | Response::HTTP_UNPROCESSABLE_ENTITY, |
|
| 24 | 1 | self::formatErrors(...$e->errors), |
|
| 25 | $e->getTrace(), |
||
| 26 | ); |
||
| 27 | } |
||
| 28 | 1 | ||
| 29 | public static function getExceptionClass(): string |
||
| 30 | 1 | { |
|
| 31 | return ValidationException::class; |
||
| 32 | } |
||
| 33 | 1 | ||
| 34 | public static function getPriority(): int |
||
| 35 | 1 | { |
|
| 36 | return 1; |
||
| 37 | } |
||
| 38 | 1 | ||
| 39 | private static function formatErrors(Error ...$errors): array |
||
| 40 | 1 | { |
|
| 41 | 1 | return ArrayList::collect($errors) |
|
| 42 | 1 | ->map(static fn (Error $error) => [$error->getField() => $error->getMessage()]) |
|
| 43 | ->reduce(array_merge(...)) |
||
|
0 ignored issues
–
show
|
|||
| 44 | ->getOrElse([]) |
||
| 45 | ; |
||
| 46 | } |
||
| 47 | } |
||
| 48 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths