@@ -40,13 +40,13 @@ |
||
40 | 40 | |
41 | 41 | public function __construct( |
42 | 42 | private readonly ConfiguratorInterface $config |
43 | - ) { |
|
43 | + ){ |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function init(EnvironmentInterface $env, DirectoriesInterface $dirs, DebugMode $debugMode): void |
47 | 47 | { |
48 | - if (!$dirs->has('locale')) { |
|
49 | - $dirs->set('locale', $dirs->get('app') . 'locale/'); |
|
48 | + if (!$dirs->has('locale')){ |
|
49 | + $dirs->set('locale', $dirs->get('app').'locale/'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $this->config->setDefaults( |
@@ -45,7 +45,8 @@ |
||
45 | 45 | |
46 | 46 | public function init(EnvironmentInterface $env, DirectoriesInterface $dirs, DebugMode $debugMode): void |
47 | 47 | { |
48 | - if (!$dirs->has('locale')) { |
|
48 | + if (!$dirs->has('locale')) |
|
49 | + { |
|
49 | 50 | $dirs->set('locale', $dirs->get('app') . 'locale/'); |
50 | 51 | } |
51 | 52 |
@@ -37,8 +37,8 @@ |
||
37 | 37 | FilesInterface $files |
38 | 38 | ): FileSnapshot { |
39 | 39 | return new FileSnapshot( |
40 | - $dirs->get('runtime') . '/snapshots/', |
|
41 | - (int) $env->get('SNAPSHOT_MAX_FILES', self::MAX_SNAPSHOTS), |
|
40 | + $dirs->get('runtime').'/snapshots/', |
|
41 | + (int)$env->get('SNAPSHOT_MAX_FILES', self::MAX_SNAPSHOTS), |
|
42 | 42 | Verbosity::tryFrom((int)($env->get('SNAPSHOT_VERBOSITY') ?? Verbosity::VERBOSE->value)), |
43 | 43 | new PlainRenderer(), |
44 | 44 | $files |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | public function __construct( |
30 | 30 | private readonly FactoryInterface $factory |
31 | - ) { |
|
31 | + ){ |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getActor(TokenInterface $token): ?object |
38 | 38 | { |
39 | - foreach ($this->getProviders() as $provider) { |
|
40 | - if (!$provider instanceof ActorProviderInterface) { |
|
39 | + foreach ($this->getProviders() as $provider){ |
|
40 | + if (!$provider instanceof ActorProviderInterface){ |
|
41 | 41 | throw new AuthException( |
42 | 42 | \sprintf( |
43 | 43 | 'Expected `ActorProviderInterface`, got `%s`', |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | $actor = $provider->getActor($token); |
50 | - if ($actor !== null) { |
|
50 | + if ($actor !== null){ |
|
51 | 51 | return $actor; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - if ($this->actorProvider === []) { |
|
55 | + if ($this->actorProvider === []){ |
|
56 | 56 | throw new AuthException('No actor provider'); |
57 | 57 | } |
58 | 58 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * Register new actor provider. |
64 | 64 | */ |
65 | - public function addActorProvider(ActorProviderInterface|Autowire|string $actorProvider): void |
|
65 | + public function addActorProvider(ActorProviderInterface | Autowire | string $actorProvider): void |
|
66 | 66 | { |
67 | 67 | $this->actorProvider[] = $actorProvider; |
68 | 68 | } |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | */ |
73 | 73 | private function getProviders(): \Generator |
74 | 74 | { |
75 | - foreach ($this->actorProvider as $provider) { |
|
76 | - if ($provider instanceof Autowire) { |
|
75 | + foreach ($this->actorProvider as $provider){ |
|
76 | + if ($provider instanceof Autowire){ |
|
77 | 77 | yield $provider->resolve($this->factory); |
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | |
81 | - if (\is_object($provider)) { |
|
81 | + if (\is_object($provider)){ |
|
82 | 82 | yield $provider; |
83 | 83 | continue; |
84 | 84 | } |
@@ -36,8 +36,10 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getActor(TokenInterface $token): ?object |
38 | 38 | { |
39 | - foreach ($this->getProviders() as $provider) { |
|
40 | - if (!$provider instanceof ActorProviderInterface) { |
|
39 | + foreach ($this->getProviders() as $provider) |
|
40 | + { |
|
41 | + if (!$provider instanceof ActorProviderInterface) |
|
42 | + { |
|
41 | 43 | throw new AuthException( |
42 | 44 | \sprintf( |
43 | 45 | 'Expected `ActorProviderInterface`, got `%s`', |
@@ -47,12 +49,14 @@ discard block |
||
47 | 49 | } |
48 | 50 | |
49 | 51 | $actor = $provider->getActor($token); |
50 | - if ($actor !== null) { |
|
52 | + if ($actor !== null) |
|
53 | + { |
|
51 | 54 | return $actor; |
52 | 55 | } |
53 | 56 | } |
54 | 57 | |
55 | - if ($this->actorProvider === []) { |
|
58 | + if ($this->actorProvider === []) |
|
59 | + { |
|
56 | 60 | throw new AuthException('No actor provider'); |
57 | 61 | } |
58 | 62 | |
@@ -72,13 +76,16 @@ discard block |
||
72 | 76 | */ |
73 | 77 | private function getProviders(): \Generator |
74 | 78 | { |
75 | - foreach ($this->actorProvider as $provider) { |
|
76 | - if ($provider instanceof Autowire) { |
|
79 | + foreach ($this->actorProvider as $provider) |
|
80 | + { |
|
81 | + if ($provider instanceof Autowire) |
|
82 | + { |
|
77 | 83 | yield $provider->resolve($this->factory); |
78 | 84 | continue; |
79 | 85 | } |
80 | 86 | |
81 | - if (\is_object($provider)) { |
|
87 | + if (\is_object($provider)) |
|
88 | + { |
|
82 | 89 | yield $provider; |
83 | 90 | continue; |
84 | 91 | } |
@@ -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 |
@@ -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 |