@@ -27,15 +27,15 @@ |
||
| 27 | 27 | public function __construct( |
| 28 | 28 | ContainerInterface $container, |
| 29 | 29 | ?ErrorsRendererInterface $renderErrors = null |
| 30 | - ) { |
|
| 30 | + ){ |
|
| 31 | 31 | $this->renderErrors = $renderErrors ?? $container->get(JsonErrorsRenderer::class); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 35 | 35 | { |
| 36 | - try { |
|
| 36 | + try{ |
|
| 37 | 37 | return $handler->handle($request); |
| 38 | - } catch (ValidationException $e) { |
|
| 38 | + }catch (ValidationException $e){ |
|
| 39 | 39 | return $this->renderErrors->render($e->errors, $e->context); |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -33,9 +33,12 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 35 | 35 | { |
| 36 | - try { |
|
| 36 | + try |
|
| 37 | + { |
|
| 37 | 38 | return $handler->handle($request); |
| 38 | - } catch (ValidationException $e) { |
|
| 39 | + } |
|
| 40 | + catch (ValidationException $e) |
|
| 41 | + { |
|
| 39 | 42 | return $this->renderErrors->render($e->errors, $e->context); |
| 40 | 43 | } |
| 41 | 44 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | { |
| 13 | 13 | public function __construct( |
| 14 | 14 | private readonly ResponseWrapper $wrapper |
| 15 | - ) { |
|
| 15 | + ){ |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function render(array $errors, mixed $context = null): ResponseInterface |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | { |
| 11 | 11 | public function __construct( |
| 12 | 12 | private readonly array $schema |
| 13 | - ) { |
|
| 13 | + ){ |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | // De-mapping |
| 23 | 23 | $mapped = []; |
| 24 | - foreach ($errors as $field => $message) { |
|
| 25 | - if (!isset($this->schema[$field])) { |
|
| 24 | + foreach ($errors as $field => $message){ |
|
| 25 | + if (!isset($this->schema[$field])){ |
|
| 26 | 26 | $mapped[$field] = $message; |
| 27 | 27 | continue; |
| 28 | 28 | } |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | private function mount(array &$array, string $path, mixed $message): void |
| 42 | 42 | { |
| 43 | - if ($path === '.') { |
|
| 43 | + if ($path === '.'){ |
|
| 44 | 44 | throw new SchemaException( |
| 45 | 45 | \sprintf('Unable to mount error `%s` to `%s` (root path is forbidden)', $message, $path) |
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $step = \explode('.', $path); |
| 50 | - while ($name = \array_shift($step)) { |
|
| 50 | + while ($name = \array_shift($step)){ |
|
| 51 | 51 | $array = &$array[$name]; |
| 52 | 52 | } |
| 53 | 53 | |