@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct( |
17 | 17 | private readonly InvokerInterface $invoker |
18 | - ) { |
|
18 | + ){ |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function getValidation(string $name, array $params = []): ValidationInterface |
33 | 33 | { |
34 | - if (!isset($this->resolvers[$name])) { |
|
34 | + if (!isset($this->resolvers[$name])){ |
|
35 | 35 | throw new ValidationException(\sprintf('Validation with name `%s` is not registered.', $name)); |
36 | 36 | } |
37 | 37 |
@@ -31,7 +31,8 @@ |
||
31 | 31 | */ |
32 | 32 | public function getValidation(string $name, array $params = []): ValidationInterface |
33 | 33 | { |
34 | - if (!isset($this->resolvers[$name])) { |
|
34 | + if (!isset($this->resolvers[$name])) |
|
35 | + { |
|
35 | 36 | throw new ValidationException(\sprintf('Validation with name `%s` is not registered.', $name)); |
36 | 37 | } |
37 | 38 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __construct( |
28 | 28 | private readonly ConfiguratorInterface $config |
29 | - ) { |
|
29 | + ){ |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function init(): void |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function setDefaultValidator(string $name): void |
43 | 43 | { |
44 | - if ($this->config->getConfig(ValidationConfig::CONFIG)['defaultValidator'] === null) { |
|
44 | + if ($this->config->getConfig(ValidationConfig::CONFIG)['defaultValidator'] === null){ |
|
45 | 45 | $this->config->modify(ValidationConfig::CONFIG, new Set('defaultValidator', $name)); |
46 | 46 | } |
47 | 47 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | ValidationConfig $config, |
54 | 54 | ValidationProviderInterface $provider |
55 | 55 | ): ValidationInterface { |
56 | - if ($config->getDefaultValidator() === null) { |
|
56 | + if ($config->getDefaultValidator() === null){ |
|
57 | 57 | throw new ValidationException('Default Validator is not configured.'); |
58 | 58 | } |
59 | 59 |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function setDefaultValidator(string $name): void |
43 | 43 | { |
44 | - if ($this->config->getConfig(ValidationConfig::CONFIG)['defaultValidator'] === null) { |
|
44 | + if ($this->config->getConfig(ValidationConfig::CONFIG)['defaultValidator'] === null) |
|
45 | + { |
|
45 | 46 | $this->config->modify(ValidationConfig::CONFIG, new Set('defaultValidator', $name)); |
46 | 47 | } |
47 | 48 | } |
@@ -53,7 +54,8 @@ discard block |
||
53 | 54 | ValidationConfig $config, |
54 | 55 | ValidationProviderInterface $provider |
55 | 56 | ): ValidationInterface { |
56 | - if ($config->getDefaultValidator() === null) { |
|
57 | + if ($config->getDefaultValidator() === null) |
|
58 | + { |
|
57 | 59 | throw new ValidationException('Default Validator is not configured.'); |
58 | 60 | } |
59 | 61 |
@@ -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 |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | * @param non-empty-string $name |
108 | 108 | * @param non-empty-string|array<non-empty-string> $value |
109 | 109 | */ |
110 | - public function withHeader(string $name, string|array $value): self |
|
110 | + public function withHeader(string $name, string | array $value): self |
|
111 | 111 | { |
112 | 112 | $value = \is_iterable($value) ? $value : [$value]; |
113 | 113 | |
114 | 114 | $self = clone $this; |
115 | 115 | $self->headers[$name] = []; |
116 | 116 | |
117 | - foreach ($value as $item) { |
|
117 | + foreach ($value as $item){ |
|
118 | 118 | $self->headers[$name][] = $item; |
119 | 119 | } |
120 | 120 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param non-empty-string $name |
126 | 126 | * @param non-empty-string|array<non-empty-string> $value |
127 | 127 | */ |
128 | - public function withAddedHeader(string $name, string|array $value): self |
|
128 | + public function withAddedHeader(string $name, string | array $value): self |
|
129 | 129 | { |
130 | 130 | /** @var iterable<non-empty-string> $value */ |
131 | 131 | $value = \is_iterable($value) ? $value : [$value]; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | /** @var array<non-empty-string> $headers */ |
134 | 134 | $headers = $this->headers[$name] ?? []; |
135 | 135 | |
136 | - foreach ($value as $item) { |
|
136 | + foreach ($value as $item){ |
|
137 | 137 | $headers[] = $item; |
138 | 138 | } |
139 | 139 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function withoutHeader(string $name): self |
147 | 147 | { |
148 | - if (!isset($this->headers[$name])) { |
|
148 | + if (!isset($this->headers[$name])){ |
|
149 | 149 | return $this; |
150 | 150 | } |
151 | 151 |
@@ -114,7 +114,8 @@ discard block |
||
114 | 114 | $self = clone $this; |
115 | 115 | $self->headers[$name] = []; |
116 | 116 | |
117 | - foreach ($value as $item) { |
|
117 | + foreach ($value as $item) |
|
118 | + { |
|
118 | 119 | $self->headers[$name][] = $item; |
119 | 120 | } |
120 | 121 | |
@@ -133,7 +134,8 @@ discard block |
||
133 | 134 | /** @var array<non-empty-string> $headers */ |
134 | 135 | $headers = $this->headers[$name] ?? []; |
135 | 136 | |
136 | - foreach ($value as $item) { |
|
137 | + foreach ($value as $item) |
|
138 | + { |
|
137 | 139 | $headers[] = $item; |
138 | 140 | } |
139 | 141 | |
@@ -145,7 +147,8 @@ discard block |
||
145 | 147 | */ |
146 | 148 | public function withoutHeader(string $name): self |
147 | 149 | { |
148 | - if (!isset($this->headers[$name])) { |
|
150 | + if (!isset($this->headers[$name])) |
|
151 | + { |
|
149 | 152 | return $this; |
150 | 153 | } |
151 | 154 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->expectExceptionMessage('Enum `Spiral\Tests\Core\Stub\EnumObject` can not be constructed.'); |
64 | 64 | |
65 | 65 | $this->resolveClosure( |
66 | - static function (EnumObject $enum) {}, |
|
66 | + static function (EnumObject $enum){}, |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | $this->resolveClosure( |
78 | - static function (TestTrait $enum) {}, |
|
78 | + static function (TestTrait $enum){}, |
|
79 | 79 | ); |
80 | 80 | } |
81 | 81 | } |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $this->expectExceptionMessage('Enum `Spiral\Tests\Core\Stub\EnumObject` can not be constructed.'); |
64 | 64 | |
65 | 65 | $this->resolveClosure( |
66 | - static function (EnumObject $enum) {}, |
|
66 | + static function (EnumObject $enum) |
|
67 | + { |
|
68 | +}, |
|
67 | 69 | ); |
68 | 70 | } |
69 | 71 | |
@@ -75,7 +77,9 @@ discard block |
||
75 | 77 | ); |
76 | 78 | |
77 | 79 | $this->resolveClosure( |
78 | - static function (TestTrait $enum) {}, |
|
80 | + static function (TestTrait $enum) |
|
81 | + { |
|
82 | +}, |
|
79 | 83 | ); |
80 | 84 | } |
81 | 85 | } |
@@ -32,13 +32,13 @@ |
||
32 | 32 | * @param non-empty-string $name |
33 | 33 | * @param non-empty-string|array<non-empty-string> $value |
34 | 34 | */ |
35 | - public function withHeader(string $name, string|array $value): self; |
|
35 | + public function withHeader(string $name, string | array $value): self; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @param non-empty-string $name |
39 | 39 | * @param non-empty-string|array<non-empty-string> $value |
40 | 40 | */ |
41 | - public function withAddedHeader(string $name, string|array $value): self; |
|
41 | + public function withAddedHeader(string $name, string | array $value): self; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @param non-empty-string $name |
@@ -12,16 +12,16 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | private readonly InvokerInterface $invoker |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function handle(string $name, string $id, array $payload, array $headers = []): void |
19 | 19 | { |
20 | - if (!isset($payload['callback'])) { |
|
20 | + if (!isset($payload['callback'])){ |
|
21 | 21 | throw new InvalidArgumentException('Payload `callback` key is required.'); |
22 | 22 | } |
23 | 23 | |
24 | - if (!$payload['callback'] instanceof \Closure) { |
|
24 | + if (!$payload['callback'] instanceof \Closure){ |
|
25 | 25 | throw new InvalidArgumentException('Payload `callback` key value type should be a closure.'); |
26 | 26 | } |
27 | 27 |
@@ -17,11 +17,13 @@ |
||
17 | 17 | |
18 | 18 | public function handle(string $name, string $id, array $payload, array $headers = []): void |
19 | 19 | { |
20 | - if (!isset($payload['callback'])) { |
|
20 | + if (!isset($payload['callback'])) |
|
21 | + { |
|
21 | 22 | throw new InvalidArgumentException('Payload `callback` key is required.'); |
22 | 23 | } |
23 | 24 | |
24 | - if (!$payload['callback'] instanceof \Closure) { |
|
25 | + if (!$payload['callback'] instanceof \Closure) |
|
26 | + { |
|
25 | 27 | throw new InvalidArgumentException('Payload `callback` key value type should be a closure.'); |
26 | 28 | } |
27 | 29 |
@@ -12,16 +12,16 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | private readonly InvokerInterface $invoker |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function handle(string $name, string $id, array $payload, array $headers = []): void |
19 | 19 | { |
20 | - if (!isset($payload['object'])) { |
|
20 | + if (!isset($payload['object'])){ |
|
21 | 21 | throw new InvalidArgumentException('Payload `object` key is required.'); |
22 | 22 | } |
23 | 23 | |
24 | - if (!\is_object($payload['object'])) { |
|
24 | + if (!\is_object($payload['object'])){ |
|
25 | 25 | throw new InvalidArgumentException('Payload `object` key value type should be an object.'); |
26 | 26 | } |
27 | 27 |
@@ -17,11 +17,13 @@ |
||
17 | 17 | |
18 | 18 | public function handle(string $name, string $id, array $payload, array $headers = []): void |
19 | 19 | { |
20 | - if (!isset($payload['object'])) { |
|
20 | + if (!isset($payload['object'])) |
|
21 | + { |
|
21 | 22 | throw new InvalidArgumentException('Payload `object` key is required.'); |
22 | 23 | } |
23 | 24 | |
24 | - if (!\is_object($payload['object'])) { |
|
25 | + if (!\is_object($payload['object'])) |
|
26 | + { |
|
25 | 27 | throw new InvalidArgumentException('Payload `object` key value type should be an object.'); |
26 | 28 | } |
27 | 29 |