@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | public function init(HttpBootloader $http): void |
18 | 18 | { |
19 | - foreach ($this->globalMiddleware() as $middleware) { |
|
19 | + foreach ($this->globalMiddleware() as $middleware){ |
|
20 | 20 | $http->addMiddleware($middleware); |
21 | 21 | } |
22 | 22 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | private function registerMiddlewareGroups(BinderInterface $binder, array $groups): void |
52 | 52 | { |
53 | - foreach ($groups as $group => $middleware) { |
|
53 | + foreach ($groups as $group => $middleware){ |
|
54 | 54 | $binder->bind( |
55 | - 'middleware:' . $group, |
|
55 | + 'middleware:'.$group, |
|
56 | 56 | static function (PipelineFactory $factory) use ($middleware): Pipeline { |
57 | 57 | return $factory->createWithMiddleware($middleware); |
58 | 58 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | |
63 | 63 | private function registerMiddlewareForRouteGroups(GroupRegistry $registry, array $groups): void |
64 | 64 | { |
65 | - foreach ($groups as $group) { |
|
66 | - $registry->getGroup($group)->addMiddleware('middleware:' . $group); |
|
65 | + foreach ($groups as $group){ |
|
66 | + $registry->getGroup($group)->addMiddleware('middleware:'.$group); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | { |
17 | 17 | public function init(HttpBootloader $http): void |
18 | 18 | { |
19 | - foreach ($this->globalMiddleware() as $middleware) { |
|
19 | + foreach ($this->globalMiddleware() as $middleware) |
|
20 | + { |
|
20 | 21 | $http->addMiddleware($middleware); |
21 | 22 | } |
22 | 23 | } |
@@ -50,7 +51,8 @@ discard block |
||
50 | 51 | |
51 | 52 | private function registerMiddlewareGroups(BinderInterface $binder, array $groups): void |
52 | 53 | { |
53 | - foreach ($groups as $group => $middleware) { |
|
54 | + foreach ($groups as $group => $middleware) |
|
55 | + { |
|
54 | 56 | $binder->bind( |
55 | 57 | 'middleware:' . $group, |
56 | 58 | static function (PipelineFactory $factory) use ($middleware): Pipeline { |
@@ -62,7 +64,8 @@ discard block |
||
62 | 64 | |
63 | 65 | private function registerMiddlewareForRouteGroups(GroupRegistry $registry, array $groups): void |
64 | 66 | { |
65 | - foreach ($groups as $group) { |
|
67 | + foreach ($groups as $group) |
|
68 | + { |
|
66 | 69 | $registry->getGroup($group)->addMiddleware('middleware:' . $group); |
67 | 70 | } |
68 | 71 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | private readonly ConfiguratorInterface $config |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function init(HttpBootloader $http): void |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function appBooting(\Closure ...$callbacks): void |
38 | 38 | { |
39 | - foreach ($callbacks as $callback) { |
|
39 | + foreach ($callbacks as $callback){ |
|
40 | 40 | $this->bootingCallbacks[] = $callback; |
41 | 41 | } |
42 | 42 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function appBooted(\Closure ...$callbacks): void |
53 | 53 | { |
54 | - foreach ($callbacks as $callback) { |
|
54 | + foreach ($callbacks as $callback){ |
|
55 | 55 | $this->bootedCallbacks[] = $callback; |
56 | 56 | } |
57 | 57 | } |
@@ -89,29 +89,29 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function mapDirectories(array $directories): array |
91 | 91 | { |
92 | - if (!isset($directories['root'])) { |
|
92 | + if (!isset($directories['root'])){ |
|
93 | 93 | throw new BootException('Missing required directory `root`'); |
94 | 94 | } |
95 | 95 | |
96 | - if (!isset($directories['app'])) { |
|
97 | - $directories['app'] = $directories['root'] . '/app/'; |
|
96 | + if (!isset($directories['app'])){ |
|
97 | + $directories['app'] = $directories['root'].'/app/'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return \array_merge( |
101 | 101 | [ |
102 | 102 | // public root |
103 | - 'public' => $directories['root'] . '/public/', |
|
103 | + 'public' => $directories['root'].'/public/', |
|
104 | 104 | |
105 | 105 | // vendor libraries |
106 | - 'vendor' => $directories['root'] . '/vendor/', |
|
106 | + 'vendor' => $directories['root'].'/vendor/', |
|
107 | 107 | |
108 | 108 | // data directories |
109 | - 'runtime' => $directories['root'] . '/runtime/', |
|
110 | - 'cache' => $directories['root'] . '/runtime/cache/', |
|
109 | + 'runtime' => $directories['root'].'/runtime/', |
|
110 | + 'cache' => $directories['root'].'/runtime/cache/', |
|
111 | 111 | |
112 | 112 | // application directories |
113 | - 'config' => $directories['app'] . '/config/', |
|
114 | - 'resources' => $directories['app'] . '/resources/', |
|
113 | + 'config' => $directories['app'].'/config/', |
|
114 | + 'resources' => $directories['app'].'/resources/', |
|
115 | 115 | ], |
116 | 116 | $directories |
117 | 117 | ); |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function appBooting(\Closure ...$callbacks): void |
38 | 38 | { |
39 | - foreach ($callbacks as $callback) { |
|
39 | + foreach ($callbacks as $callback) |
|
40 | + { |
|
40 | 41 | $this->bootingCallbacks[] = $callback; |
41 | 42 | } |
42 | 43 | } |
@@ -51,7 +52,8 @@ discard block |
||
51 | 52 | */ |
52 | 53 | public function appBooted(\Closure ...$callbacks): void |
53 | 54 | { |
54 | - foreach ($callbacks as $callback) { |
|
55 | + foreach ($callbacks as $callback) |
|
56 | + { |
|
55 | 57 | $this->bootedCallbacks[] = $callback; |
56 | 58 | } |
57 | 59 | } |
@@ -89,11 +91,13 @@ discard block |
||
89 | 91 | */ |
90 | 92 | protected function mapDirectories(array $directories): array |
91 | 93 | { |
92 | - if (!isset($directories['root'])) { |
|
94 | + if (!isset($directories['root'])) |
|
95 | + { |
|
93 | 96 | throw new BootException('Missing required directory `root`'); |
94 | 97 | } |
95 | 98 | |
96 | - if (!isset($directories['app'])) { |
|
99 | + if (!isset($directories['app'])) |
|
100 | + { |
|
97 | 101 | $directories['app'] = $directories['root'] . '/app/'; |
98 | 102 | } |
99 | 103 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function __construct( |
21 | 21 | private readonly ContainerInterface $container, |
22 | 22 | private readonly FactoryInterface $factory |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
30 | 30 | { |
31 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
31 | + if (!$this->container->has(ServerRequestInterface::class)){ |
|
32 | 32 | throw new ScopeException('Unable to create paginator, no request scope found'); |
33 | 33 | } |
34 | 34 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | //Getting page number |
40 | 40 | $page = 0; |
41 | - if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) { |
|
41 | + if (!empty($query[$parameter]) && \is_scalar($query[$parameter])){ |
|
42 | 42 | $page = (int)$query[$parameter]; |
43 | 43 | } |
44 | 44 |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
30 | 30 | { |
31 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
31 | + if (!$this->container->has(ServerRequestInterface::class)) |
|
32 | + { |
|
32 | 33 | throw new ScopeException('Unable to create paginator, no request scope found'); |
33 | 34 | } |
34 | 35 | /** |
@@ -38,7 +39,8 @@ discard block |
||
38 | 39 | |
39 | 40 | //Getting page number |
40 | 41 | $page = 0; |
41 | - if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) { |
|
42 | + if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) |
|
43 | + { |
|
42 | 44 | $page = (int)$query[$parameter]; |
43 | 45 | } |
44 | 46 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | { |
26 | 26 | $pipeline = new Pipeline(new Container()); |
27 | 27 | |
28 | - $handler = new CallableHandler(function () { |
|
28 | + $handler = new CallableHandler(function (){ |
|
29 | 29 | return 'response'; |
30 | 30 | }, new ResponseFactory(new HttpConfig(['headers' => []]))); |
31 | 31 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | { |
41 | 41 | $pipeline = new Pipeline(new Container()); |
42 | 42 | |
43 | - $handler = new CallableHandler(function () { |
|
43 | + $handler = new CallableHandler(function (){ |
|
44 | 44 | return 'response'; |
45 | 45 | }, new ResponseFactory(new HttpConfig(['headers' => []]))); |
46 | 46 | |
@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | |
62 | 62 | public function testMiddlewareProcessingEventShouldBeDispatched(): void |
63 | 63 | { |
64 | - $middleware = new class implements MiddlewareInterface { |
|
64 | + $middleware = new class implements MiddlewareInterface{ |
|
65 | 65 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
66 | 66 | { |
67 | 67 | return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200); |
68 | 68 | } |
69 | 69 | }; |
70 | 70 | $request = new ServerRequest('GET', ''); |
71 | - $handler = new CallableHandler(function () { |
|
71 | + $handler = new CallableHandler(function (){ |
|
72 | 72 | return 'response'; |
73 | 73 | }, new ResponseFactory(new HttpConfig(['headers' => []]))); |
74 | 74 |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | { |
26 | 26 | $pipeline = new Pipeline(new Container()); |
27 | 27 | |
28 | - $handler = new CallableHandler(function () { |
|
28 | + $handler = new CallableHandler(function () |
|
29 | + { |
|
29 | 30 | return 'response'; |
30 | 31 | }, new ResponseFactory(new HttpConfig(['headers' => []]))); |
31 | 32 | |
@@ -40,7 +41,8 @@ discard block |
||
40 | 41 | { |
41 | 42 | $pipeline = new Pipeline(new Container()); |
42 | 43 | |
43 | - $handler = new CallableHandler(function () { |
|
44 | + $handler = new CallableHandler(function () |
|
45 | + { |
|
44 | 46 | return 'response'; |
45 | 47 | }, new ResponseFactory(new HttpConfig(['headers' => []]))); |
46 | 48 | |
@@ -61,14 +63,16 @@ discard block |
||
61 | 63 | |
62 | 64 | public function testMiddlewareProcessingEventShouldBeDispatched(): void |
63 | 65 | { |
64 | - $middleware = new class implements MiddlewareInterface { |
|
66 | + $middleware = new class implements MiddlewareInterface |
|
67 | + { |
|
65 | 68 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
66 | 69 | { |
67 | 70 | return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200); |
68 | 71 | } |
69 | 72 | }; |
70 | 73 | $request = new ServerRequest('GET', ''); |
71 | - $handler = new CallableHandler(function () { |
|
74 | + $handler = new CallableHandler(function () |
|
75 | + { |
|
72 | 76 | return 'response'; |
73 | 77 | }, new ResponseFactory(new HttpConfig(['headers' => []]))); |
74 | 78 |
@@ -23,11 +23,11 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null) |
25 | 25 | { |
26 | - if (empty($code) && empty($this->code)) { |
|
26 | + if (empty($code) && empty($this->code)){ |
|
27 | 27 | $code = self::BAD_DATA; |
28 | 28 | } |
29 | 29 | |
30 | - if (empty($message)) { |
|
30 | + if (empty($message)){ |
|
31 | 31 | $message = \sprintf('Http Error - %s', $code); |
32 | 32 | } |
33 | 33 |
@@ -23,11 +23,13 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null) |
25 | 25 | { |
26 | - if (empty($code) && empty($this->code)) { |
|
26 | + if (empty($code) && empty($this->code)) |
|
27 | + { |
|
27 | 28 | $code = self::BAD_DATA; |
28 | 29 | } |
29 | 30 | |
30 | - if (empty($message)) { |
|
31 | + if (empty($message)) |
|
32 | + { |
|
31 | 33 | $message = \sprintf('Http Error - %s', $code); |
32 | 34 | } |
33 | 35 |
@@ -16,11 +16,11 @@ |
||
16 | 16 | */ |
17 | 17 | private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface |
18 | 18 | { |
19 | - if ($payload instanceof \JsonSerializable) { |
|
19 | + if ($payload instanceof \JsonSerializable){ |
|
20 | 20 | $payload = $payload->jsonSerialize(); |
21 | 21 | } |
22 | 22 | |
23 | - if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) { |
|
23 | + if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])){ |
|
24 | 24 | $code = $payload['status']; |
25 | 25 | } |
26 | 26 |
@@ -16,11 +16,13 @@ |
||
16 | 16 | */ |
17 | 17 | private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface |
18 | 18 | { |
19 | - if ($payload instanceof \JsonSerializable) { |
|
19 | + if ($payload instanceof \JsonSerializable) |
|
20 | + { |
|
20 | 21 | $payload = $payload->jsonSerialize(); |
21 | 22 | } |
22 | 23 | |
23 | - if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) { |
|
24 | + if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) |
|
25 | + { |
|
24 | 26 | $code = $payload['status']; |
25 | 27 | } |
26 | 28 |
@@ -12,6 +12,6 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | public readonly ServerRequestInterface $request, |
14 | 14 | public readonly MiddlewareInterface $middleware |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -12,6 +12,6 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | public readonly ServerRequestInterface $request, |
14 | 14 | public readonly ResponseInterface $response |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |