@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function handle(string $name, string $id, $payload): void |
50 | 50 | { |
51 | - if (\is_string($payload)) { |
|
51 | + if (\is_string($payload)){ |
|
52 | 52 | $payload = json_decode($payload, true); |
53 | 53 | } |
54 | 54 | |
55 | - if (!\is_array($payload)) { |
|
55 | + if (!\is_array($payload)){ |
|
56 | 56 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
57 | 57 | } |
58 | 58 | |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | |
61 | 61 | $email = $this->renderer->render($message); |
62 | 62 | |
63 | - if ($email->getFrom() === []) { |
|
63 | + if ($email->getFrom() === []){ |
|
64 | 64 | $email->from(Address::create($this->config->getFromAddress())); |
65 | 65 | } |
66 | 66 | |
67 | 67 | $recipients = $this->getRecipients($email); |
68 | 68 | |
69 | - try { |
|
69 | + try{ |
|
70 | 70 | $this->mailer->send($email); |
71 | - } catch (TransportExceptionInterface $e) { |
|
71 | + }catch (TransportExceptionInterface $e){ |
|
72 | 72 | $this->getLogger()->error( |
73 | 73 | sprintf( |
74 | 74 | 'Failed to send `%s` to "%s": %s', |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
100 | 100 | |
101 | - foreach ($addresses as $address) { |
|
101 | + foreach ($addresses as $address){ |
|
102 | 102 | $emails[] = $address->toString(); |
103 | 103 | } |
104 | 104 |
@@ -48,11 +48,13 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function handle(string $name, string $id, $payload): void |
50 | 50 | { |
51 | - if (\is_string($payload)) { |
|
51 | + if (\is_string($payload)) |
|
52 | + { |
|
52 | 53 | $payload = json_decode($payload, true); |
53 | 54 | } |
54 | 55 | |
55 | - if (!\is_array($payload)) { |
|
56 | + if (!\is_array($payload)) |
|
57 | + { |
|
56 | 58 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
57 | 59 | } |
58 | 60 | |
@@ -60,15 +62,19 @@ discard block |
||
60 | 62 | |
61 | 63 | $email = $this->renderer->render($message); |
62 | 64 | |
63 | - if ($email->getFrom() === []) { |
|
65 | + if ($email->getFrom() === []) |
|
66 | + { |
|
64 | 67 | $email->from(Address::create($this->config->getFromAddress())); |
65 | 68 | } |
66 | 69 | |
67 | 70 | $recipients = $this->getRecipients($email); |
68 | 71 | |
69 | - try { |
|
72 | + try |
|
73 | + { |
|
70 | 74 | $this->mailer->send($email); |
71 | - } catch (TransportExceptionInterface $e) { |
|
75 | + } |
|
76 | + catch (TransportExceptionInterface $e) |
|
77 | + { |
|
72 | 78 | $this->getLogger()->error( |
73 | 79 | sprintf( |
74 | 80 | 'Failed to send `%s` to "%s": %s', |
@@ -98,7 +104,8 @@ discard block |
||
98 | 104 | |
99 | 105 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
100 | 106 | |
101 | - foreach ($addresses as $address) { |
|
107 | + foreach ($addresses as $address) |
|
108 | + { |
|
102 | 109 | $emails[] = $address->toString(); |
103 | 110 | } |
104 | 111 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | // Replaces alias with real pipeline name |
30 | 30 | $name = $this->config->getAliases()[$name] ?? $name; |
31 | 31 | |
32 | - if (!isset($this->pipelines[$name])) { |
|
32 | + if (!isset($this->pipelines[$name])){ |
|
33 | 33 | $this->pipelines[$name] = $this->resolveConnection($name); |
34 | 34 | } |
35 | 35 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | { |
45 | 45 | $config = $this->config->getConnection($name); |
46 | 46 | |
47 | - try { |
|
47 | + try{ |
|
48 | 48 | return $this->factory->make($config['driver'], $config); |
49 | - } catch (ContainerException $e) { |
|
49 | + }catch (ContainerException $e){ |
|
50 | 50 | throw new Exception\NotSupportedDriverException( |
51 | 51 | \sprintf( |
52 | 52 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -29,7 +29,8 @@ discard block |
||
29 | 29 | // Replaces alias with real pipeline name |
30 | 30 | $name = $this->config->getAliases()[$name] ?? $name; |
31 | 31 | |
32 | - if (!isset($this->pipelines[$name])) { |
|
32 | + if (!isset($this->pipelines[$name])) |
|
33 | + { |
|
33 | 34 | $this->pipelines[$name] = $this->resolveConnection($name); |
34 | 35 | } |
35 | 36 | |
@@ -44,9 +45,12 @@ discard block |
||
44 | 45 | { |
45 | 46 | $config = $this->config->getConnection($name); |
46 | 47 | |
47 | - try { |
|
48 | + try |
|
49 | + { |
|
48 | 50 | return $this->factory->make($config['driver'], $config); |
49 | - } catch (ContainerException $e) { |
|
51 | + } |
|
52 | + catch (ContainerException $e) |
|
53 | + { |
|
50 | 54 | throw new Exception\NotSupportedDriverException( |
51 | 55 | \sprintf( |
52 | 56 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | public function findDeclarations(): array |
48 | 48 | { |
49 | 49 | $result = []; |
50 | - foreach ($this->locator->getScopedClasses('routes') as $class) { |
|
51 | - foreach ($class->getMethods() as $method) { |
|
50 | + foreach ($this->locator->getScopedClasses('routes') as $class){ |
|
51 | + foreach ($class->getMethods() as $method){ |
|
52 | 52 | $route = $this->reader->firstFunctionMetadata($method, Route::class); |
53 | 53 | |
54 | - if ($route === null) { |
|
54 | + if ($route === null){ |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | 'controller' => $class->getName(), |
62 | 62 | 'action' => $method->getName(), |
63 | 63 | 'group' => $route->group, |
64 | - 'verbs' => (array) $route->methods, |
|
64 | + 'verbs' => (array)$route->methods, |
|
65 | 65 | 'defaults' => $route->defaults, |
66 | - 'middleware' => (array) $route->middleware, |
|
66 | + 'middleware' => (array)$route->middleware, |
|
67 | 67 | 'priority' => $route->priority, |
68 | 68 | ]; |
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - \uasort($result, static function (array $route1, array $route2) { |
|
72 | + \uasort($result, static function (array $route1, array $route2){ |
|
73 | 73 | return $route1['priority'] <=> $route2['priority']; |
74 | 74 | }); |
75 | 75 |
@@ -47,11 +47,14 @@ discard block |
||
47 | 47 | public function findDeclarations(): array |
48 | 48 | { |
49 | 49 | $result = []; |
50 | - foreach ($this->locator->getScopedClasses('routes') as $class) { |
|
51 | - foreach ($class->getMethods() as $method) { |
|
50 | + foreach ($this->locator->getScopedClasses('routes') as $class) |
|
51 | + { |
|
52 | + foreach ($class->getMethods() as $method) |
|
53 | + { |
|
52 | 54 | $route = $this->reader->firstFunctionMetadata($method, Route::class); |
53 | 55 | |
54 | - if ($route === null) { |
|
56 | + if ($route === null) |
|
57 | + { |
|
55 | 58 | continue; |
56 | 59 | } |
57 | 60 | |
@@ -69,7 +72,8 @@ discard block |
||
69 | 72 | } |
70 | 73 | } |
71 | 74 | |
72 | - \uasort($result, static function (array $route1, array $route2) { |
|
75 | + \uasort($result, static function (array $route1, array $route2) |
|
76 | + { |
|
73 | 77 | return $route1['priority'] <=> $route2['priority']; |
74 | 78 | }); |
75 | 79 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $manager = new CacheManager($config, $container); |
57 | 57 | |
58 | - foreach ($config->getAliases() as $alias => $storageName) { |
|
58 | + foreach ($config->getAliases() as $alias => $storageName){ |
|
59 | 59 | $container->bind($alias, static function (CacheManager $manager) use ($storageName) { |
60 | 60 | return $manager->storage($storageName); |
61 | 61 | }); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ], |
78 | 78 | 'file' => [ |
79 | 79 | 'type' => 'file', |
80 | - 'path' => $dirs->get('runtime') . 'cache', |
|
80 | + 'path' => $dirs->get('runtime').'cache', |
|
81 | 81 | ], |
82 | 82 | ], |
83 | 83 | 'typeAliases' => [ |
@@ -55,8 +55,10 @@ |
||
55 | 55 | { |
56 | 56 | $manager = new CacheManager($config, $container); |
57 | 57 | |
58 | - foreach ($config->getAliases() as $alias => $storageName) { |
|
59 | - $container->bind($alias, static function (CacheManager $manager) use ($storageName) { |
|
58 | + foreach ($config->getAliases() as $alias => $storageName) |
|
59 | + { |
|
60 | + $container->bind($alias, static function (CacheManager $manager) use ($storageName) |
|
61 | + { |
|
60 | 62 | return $manager->storage($storageName); |
61 | 63 | }); |
62 | 64 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | CoreInterface $core, |
57 | 57 | ScopeInterface $scope, |
58 | 58 | ResponseFactoryInterface $responseFactory |
59 | - ) { |
|
59 | + ){ |
|
60 | 60 | $this->core = $core; |
61 | 61 | $this->scope = $scope; |
62 | 62 | $this->responseFactory = $responseFactory; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function handle(Request $request): Response |
96 | 96 | { |
97 | - if ($this->controller === null) { |
|
97 | + if ($this->controller === null){ |
|
98 | 98 | throw new HandlerException('Controller and action pair is not set'); |
99 | 99 | } |
100 | 100 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $output = $result = null; |
105 | 105 | |
106 | 106 | $response = $this->responseFactory->createResponse(200); |
107 | - try { |
|
107 | + try{ |
|
108 | 108 | // run the core withing PSR-7 Request/Response scope |
109 | 109 | $result = $this->scope->runScope( |
110 | 110 | [ |
@@ -119,29 +119,29 @@ discard block |
||
119 | 119 | ); |
120 | 120 | } |
121 | 121 | ); |
122 | - } catch (ControllerException $e) { |
|
122 | + }catch (ControllerException $e){ |
|
123 | 123 | ob_get_clean(); |
124 | 124 | throw $this->mapException($e); |
125 | - } catch (\Throwable $e) { |
|
125 | + }catch (\Throwable $e){ |
|
126 | 126 | ob_get_clean(); |
127 | 127 | throw $e; |
128 | - } finally { |
|
129 | - while (ob_get_level() > $outputLevel + 1) { |
|
130 | - $output = ob_get_clean() . $output; |
|
128 | + }finally{ |
|
129 | + while (ob_get_level() > $outputLevel + 1){ |
|
130 | + $output = ob_get_clean().$output; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | 134 | return $this->wrapResponse( |
135 | 135 | $response, |
136 | 136 | $result, |
137 | - ob_get_clean() . $output |
|
137 | + ob_get_clean().$output |
|
138 | 138 | ); |
139 | 139 | } |
140 | 140 | |
141 | 141 | private function getAction(Request $request): string |
142 | 142 | { |
143 | - if ($this->verbActions) { |
|
144 | - return strtolower($request->getMethod()) . ucfirst($this->action); |
|
143 | + if ($this->verbActions){ |
|
144 | + return strtolower($request->getMethod()).ucfirst($this->action); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | return $this->action; |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function wrapResponse(Response $response, $result = null, string $output = ''): Response |
158 | 158 | { |
159 | - if ($result instanceof Response) { |
|
160 | - if ($output !== '' && $result->getBody()->isWritable()) { |
|
159 | + if ($result instanceof Response){ |
|
160 | + if ($output !== '' && $result->getBody()->isWritable()){ |
|
161 | 161 | $result->getBody()->write($output); |
162 | 162 | } |
163 | 163 | |
164 | 164 | return $result; |
165 | 165 | } |
166 | 166 | |
167 | - if ($result instanceof \Generator) { |
|
167 | + if ($result instanceof \Generator){ |
|
168 | 168 | return $response->withBody(new GeneratorStream($result)); |
169 | 169 | } |
170 | 170 | |
171 | - if (\is_array($result) || $result instanceof \JsonSerializable) { |
|
171 | + if (\is_array($result) || $result instanceof \JsonSerializable){ |
|
172 | 172 | $response = $this->writeJson($response, $result); |
173 | - } else { |
|
173 | + }else{ |
|
174 | 174 | $response->getBody()->write((string)$result); |
175 | 175 | } |
176 | 176 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | private function mapException(ControllerException $exception): ClientException |
187 | 187 | { |
188 | - switch ($exception->getCode()) { |
|
188 | + switch ($exception->getCode()){ |
|
189 | 189 | case ControllerException::BAD_ACTION: |
190 | 190 | case ControllerException::NOT_FOUND: |
191 | 191 | return new NotFoundException($exception->getMessage()); |
@@ -94,7 +94,8 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function handle(Request $request): Response |
96 | 96 | { |
97 | - if ($this->controller === null) { |
|
97 | + if ($this->controller === null) |
|
98 | + { |
|
98 | 99 | throw new HandlerException('Controller and action pair is not set'); |
99 | 100 | } |
100 | 101 | |
@@ -104,14 +105,16 @@ discard block |
||
104 | 105 | $output = $result = null; |
105 | 106 | |
106 | 107 | $response = $this->responseFactory->createResponse(200); |
107 | - try { |
|
108 | + try |
|
109 | + { |
|
108 | 110 | // run the core withing PSR-7 Request/Response scope |
109 | 111 | $result = $this->scope->runScope( |
110 | 112 | [ |
111 | 113 | Request::class => $request, |
112 | 114 | Response::class => $response, |
113 | 115 | ], |
114 | - function () use ($request) { |
|
116 | + function () use ($request) |
|
117 | + { |
|
115 | 118 | return $this->core->callAction( |
116 | 119 | $this->controller, |
117 | 120 | $this->getAction($request), |
@@ -119,14 +122,21 @@ discard block |
||
119 | 122 | ); |
120 | 123 | } |
121 | 124 | ); |
122 | - } catch (ControllerException $e) { |
|
125 | + } |
|
126 | + catch (ControllerException $e) |
|
127 | + { |
|
123 | 128 | ob_get_clean(); |
124 | 129 | throw $this->mapException($e); |
125 | - } catch (\Throwable $e) { |
|
130 | + } |
|
131 | + catch (\Throwable $e) |
|
132 | + { |
|
126 | 133 | ob_get_clean(); |
127 | 134 | throw $e; |
128 | - } finally { |
|
129 | - while (ob_get_level() > $outputLevel + 1) { |
|
135 | + } |
|
136 | + finally |
|
137 | + { |
|
138 | + while (ob_get_level() > $outputLevel + 1) |
|
139 | + { |
|
130 | 140 | $output = ob_get_clean() . $output; |
131 | 141 | } |
132 | 142 | } |
@@ -140,7 +150,8 @@ discard block |
||
140 | 150 | |
141 | 151 | private function getAction(Request $request): string |
142 | 152 | { |
143 | - if ($this->verbActions) { |
|
153 | + if ($this->verbActions) |
|
154 | + { |
|
144 | 155 | return strtolower($request->getMethod()) . ucfirst($this->action); |
145 | 156 | } |
146 | 157 | |
@@ -156,21 +167,27 @@ discard block |
||
156 | 167 | */ |
157 | 168 | private function wrapResponse(Response $response, $result = null, string $output = ''): Response |
158 | 169 | { |
159 | - if ($result instanceof Response) { |
|
160 | - if ($output !== '' && $result->getBody()->isWritable()) { |
|
170 | + if ($result instanceof Response) |
|
171 | + { |
|
172 | + if ($output !== '' && $result->getBody()->isWritable()) |
|
173 | + { |
|
161 | 174 | $result->getBody()->write($output); |
162 | 175 | } |
163 | 176 | |
164 | 177 | return $result; |
165 | 178 | } |
166 | 179 | |
167 | - if ($result instanceof \Generator) { |
|
180 | + if ($result instanceof \Generator) |
|
181 | + { |
|
168 | 182 | return $response->withBody(new GeneratorStream($result)); |
169 | 183 | } |
170 | 184 | |
171 | - if (\is_array($result) || $result instanceof \JsonSerializable) { |
|
185 | + if (\is_array($result) || $result instanceof \JsonSerializable) |
|
186 | + { |
|
172 | 187 | $response = $this->writeJson($response, $result); |
173 | - } else { |
|
188 | + } |
|
189 | + else |
|
190 | + { |
|
174 | 191 | $response->getBody()->write((string)$result); |
175 | 192 | } |
176 | 193 | |
@@ -185,7 +202,8 @@ discard block |
||
185 | 202 | */ |
186 | 203 | private function mapException(ControllerException $exception): ClientException |
187 | 204 | { |
188 | - switch ($exception->getCode()) { |
|
205 | + switch ($exception->getCode()) |
|
206 | + { |
|
189 | 207 | case ControllerException::BAD_ACTION: |
190 | 208 | case ControllerException::NOT_FOUND: |
191 | 209 | return new NotFoundException($exception->getMessage()); |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | public function initAnnotations(ContainerInterface $container, bool $reset = false): void |
125 | 125 | { |
126 | 126 | $prototyped = $this->memory->loadData('prototyped'); |
127 | - if (!$reset && $prototyped !== null) { |
|
128 | - foreach ($prototyped as $property => $class) { |
|
127 | + if (!$reset && $prototyped !== null){ |
|
128 | + foreach ($prototyped as $property => $class){ |
|
129 | 129 | $this->bindProperty($property, $class); |
130 | 130 | } |
131 | 131 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | $reader = $container->get(ReaderInterface::class); |
138 | 138 | |
139 | 139 | $prototyped = []; |
140 | - foreach ($locator->getClasses() as $class) { |
|
140 | + foreach ($locator->getClasses() as $class){ |
|
141 | 141 | $meta = $reader->firstClassMetadata($class, Prototyped::class); |
142 | 142 | |
143 | - if ($meta === null) { |
|
143 | + if ($meta === null){ |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
@@ -156,19 +156,19 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function initCycle(ContainerInterface $container): void |
158 | 158 | { |
159 | - if (!$container->has(ORM\SchemaInterface::class)) { |
|
159 | + if (!$container->has(ORM\SchemaInterface::class)){ |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | /** @var ORM\SchemaInterface|null $schema */ |
164 | 164 | $schema = $container->get(ORM\SchemaInterface::class); |
165 | - if ($schema === null) { |
|
165 | + if ($schema === null){ |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
169 | - foreach ($schema->getRoles() as $role) { |
|
169 | + foreach ($schema->getRoles() as $role){ |
|
170 | 170 | $repository = $schema->define($role, ORM\SchemaInterface::REPOSITORY); |
171 | - if ($repository === ORM\Select\Repository::class || $repository === null) { |
|
171 | + if ($repository === ORM\Select\Repository::class || $repository === null){ |
|
172 | 172 | // default repository can not be wired |
173 | 173 | continue; |
174 | 174 | } |
@@ -179,23 +179,23 @@ discard block |
||
179 | 179 | |
180 | 180 | private function initDefaults(ContainerInterface $container): void |
181 | 181 | { |
182 | - foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut) { |
|
183 | - if (is_array($shortcut) && isset($shortcut['resolve'])) { |
|
184 | - if (isset($shortcut['with'])) { |
|
182 | + foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut){ |
|
183 | + if (is_array($shortcut) && isset($shortcut['resolve'])){ |
|
184 | + if (isset($shortcut['with'])){ |
|
185 | 185 | // check dependencies |
186 | - foreach ($shortcut['with'] as $dep) { |
|
187 | - if (!class_exists($dep, true) && !interface_exists($dep, true)) { |
|
186 | + foreach ($shortcut['with'] as $dep){ |
|
187 | + if (!class_exists($dep, true) && !interface_exists($dep, true)){ |
|
188 | 188 | continue 2; |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | - try { |
|
193 | + try{ |
|
194 | 194 | $target = $container->get($shortcut['resolve']); |
195 | - if (is_object($target)) { |
|
195 | + if (is_object($target)){ |
|
196 | 196 | $this->bindProperty($property, get_class($target)); |
197 | 197 | } |
198 | - } catch (ContainerExceptionInterface $e) { |
|
198 | + }catch (ContainerExceptionInterface $e){ |
|
199 | 199 | continue; |
200 | 200 | } |
201 | 201 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | is_string($shortcut) |
207 | 207 | && (class_exists($shortcut, true) |
208 | 208 | || interface_exists($shortcut, true)) |
209 | - ) { |
|
209 | + ){ |
|
210 | 210 | $this->bindProperty($property, $shortcut); |
211 | 211 | } |
212 | 212 | } |
@@ -124,8 +124,10 @@ discard block |
||
124 | 124 | public function initAnnotations(ContainerInterface $container, bool $reset = false): void |
125 | 125 | { |
126 | 126 | $prototyped = $this->memory->loadData('prototyped'); |
127 | - if (!$reset && $prototyped !== null) { |
|
128 | - foreach ($prototyped as $property => $class) { |
|
127 | + if (!$reset && $prototyped !== null) |
|
128 | + { |
|
129 | + foreach ($prototyped as $property => $class) |
|
130 | + { |
|
129 | 131 | $this->bindProperty($property, $class); |
130 | 132 | } |
131 | 133 | |
@@ -137,10 +139,12 @@ discard block |
||
137 | 139 | $reader = $container->get(ReaderInterface::class); |
138 | 140 | |
139 | 141 | $prototyped = []; |
140 | - foreach ($locator->getClasses() as $class) { |
|
142 | + foreach ($locator->getClasses() as $class) |
|
143 | + { |
|
141 | 144 | $meta = $reader->firstClassMetadata($class, Prototyped::class); |
142 | 145 | |
143 | - if ($meta === null) { |
|
146 | + if ($meta === null) |
|
147 | + { |
|
144 | 148 | continue; |
145 | 149 | } |
146 | 150 | |
@@ -156,19 +160,23 @@ discard block |
||
156 | 160 | */ |
157 | 161 | public function initCycle(ContainerInterface $container): void |
158 | 162 | { |
159 | - if (!$container->has(ORM\SchemaInterface::class)) { |
|
163 | + if (!$container->has(ORM\SchemaInterface::class)) |
|
164 | + { |
|
160 | 165 | return; |
161 | 166 | } |
162 | 167 | |
163 | 168 | /** @var ORM\SchemaInterface|null $schema */ |
164 | 169 | $schema = $container->get(ORM\SchemaInterface::class); |
165 | - if ($schema === null) { |
|
170 | + if ($schema === null) |
|
171 | + { |
|
166 | 172 | return; |
167 | 173 | } |
168 | 174 | |
169 | - foreach ($schema->getRoles() as $role) { |
|
175 | + foreach ($schema->getRoles() as $role) |
|
176 | + { |
|
170 | 177 | $repository = $schema->define($role, ORM\SchemaInterface::REPOSITORY); |
171 | - if ($repository === ORM\Select\Repository::class || $repository === null) { |
|
178 | + if ($repository === ORM\Select\Repository::class || $repository === null) |
|
179 | + { |
|
172 | 180 | // default repository can not be wired |
173 | 181 | continue; |
174 | 182 | } |
@@ -179,23 +187,32 @@ discard block |
||
179 | 187 | |
180 | 188 | private function initDefaults(ContainerInterface $container): void |
181 | 189 | { |
182 | - foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut) { |
|
183 | - if (is_array($shortcut) && isset($shortcut['resolve'])) { |
|
184 | - if (isset($shortcut['with'])) { |
|
190 | + foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut) |
|
191 | + { |
|
192 | + if (is_array($shortcut) && isset($shortcut['resolve'])) |
|
193 | + { |
|
194 | + if (isset($shortcut['with'])) |
|
195 | + { |
|
185 | 196 | // check dependencies |
186 | - foreach ($shortcut['with'] as $dep) { |
|
187 | - if (!class_exists($dep, true) && !interface_exists($dep, true)) { |
|
197 | + foreach ($shortcut['with'] as $dep) |
|
198 | + { |
|
199 | + if (!class_exists($dep, true) && !interface_exists($dep, true)) |
|
200 | + { |
|
188 | 201 | continue 2; |
189 | 202 | } |
190 | 203 | } |
191 | 204 | } |
192 | 205 | |
193 | - try { |
|
206 | + try |
|
207 | + { |
|
194 | 208 | $target = $container->get($shortcut['resolve']); |
195 | - if (is_object($target)) { |
|
209 | + if (is_object($target)) |
|
210 | + { |
|
196 | 211 | $this->bindProperty($property, get_class($target)); |
197 | 212 | } |
198 | - } catch (ContainerExceptionInterface $e) { |
|
213 | + } |
|
214 | + catch (ContainerExceptionInterface $e) |
|
215 | + { |
|
199 | 216 | continue; |
200 | 217 | } |
201 | 218 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | protected function formatTopics(array $topics): array |
18 | 18 | { |
19 | - return array_map(function ($topic) { |
|
19 | + return array_map(function ($topic){ |
|
20 | 20 | return (string)$topic; |
21 | 21 | }, $topics); |
22 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | protected function toArray($entries): array |
30 | 30 | { |
31 | - switch (true) { |
|
31 | + switch (true){ |
|
32 | 32 | case \is_array($entries): |
33 | 33 | return $entries; |
34 | 34 |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | */ |
17 | 17 | protected function formatTopics(array $topics): array |
18 | 18 | { |
19 | - return array_map(function ($topic) { |
|
19 | + return array_map(function ($topic) |
|
20 | + { |
|
20 | 21 | return (string)$topic; |
21 | 22 | }, $topics); |
22 | 23 | } |
@@ -28,7 +29,8 @@ discard block |
||
28 | 29 | */ |
29 | 30 | protected function toArray($entries): array |
30 | 31 | { |
31 | - switch (true) { |
|
32 | + switch (true) |
|
33 | + { |
|
32 | 34 | case \is_array($entries): |
33 | 35 | return $entries; |
34 | 36 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | }); |
36 | 36 | |
37 | 37 | |
38 | - if ($config->getAuthorizationPath() !== null) { |
|
38 | + if ($config->getAuthorizationPath() !== null){ |
|
39 | 39 | $http->addMiddleware(AuthorizationMiddleware::class); |
40 | 40 | } |
41 | 41 | } |
@@ -35,7 +35,8 @@ |
||
35 | 35 | }); |
36 | 36 | |
37 | 37 | |
38 | - if ($config->getAuthorizationPath() !== null) { |
|
38 | + if ($config->getAuthorizationPath() !== null) |
|
39 | + { |
|
39 | 40 | $http->addMiddleware(AuthorizationMiddleware::class); |
40 | 41 | } |
41 | 42 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function start(Container $container): void |
70 | 70 | { |
71 | - if ($container->has(JobRegistry::class)) { |
|
71 | + if ($container->has(JobRegistry::class)){ |
|
72 | 72 | // Will be removed since v3.0 |
73 | 73 | $registry = $container->get(JobRegistry::class); |
74 | 74 | $registry->setHandler(MailQueue::JOB_NAME, \Spiral\SendIt\Jobs\MailJobAdapter::class); |
@@ -77,19 +77,19 @@ discard block |
||
77 | 77 | $container->bindSingleton( |
78 | 78 | MailerInterface::class, |
79 | 79 | static function (MailerConfig $config) use ($container) { |
80 | - if ($config->getQueueConnection() === 'sync') { |
|
80 | + if ($config->getQueueConnection() === 'sync'){ |
|
81 | 81 | $queue = $container->get(ShortCircuit::class); |
82 | - } else { |
|
82 | + }else{ |
|
83 | 83 | $queue = $container->get(QueueInterface::class); |
84 | 84 | } |
85 | 85 | |
86 | 86 | return new MailQueue($config, $queue); |
87 | 87 | } |
88 | 88 | ); |
89 | - } else { |
|
89 | + }else{ |
|
90 | 90 | $container->bindSingleton( |
91 | 91 | MailerInterface::class, |
92 | - static function (MailerConfig $config, QueueConnectionProviderInterface $provider) { |
|
92 | + static function (MailerConfig $config, QueueConnectionProviderInterface $provider){ |
|
93 | 93 | return new MailQueue( |
94 | 94 | $config, |
95 | 95 | $provider->getConnection($config->getQueueConnection()) |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | - if ($container->has(HandlerRegistryInterface::class)) { |
|
101 | + if ($container->has(HandlerRegistryInterface::class)){ |
|
102 | 102 | $registry = $container->get(HandlerRegistryInterface::class); |
103 | 103 | $registry->setHandler(MailQueue::JOB_NAME, \Spiral\SendIt\MailJob::class); |
104 | 104 | } |
@@ -68,7 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | public function start(Container $container): void |
70 | 70 | { |
71 | - if ($container->has(JobRegistry::class)) { |
|
71 | + if ($container->has(JobRegistry::class)) |
|
72 | + { |
|
72 | 73 | // Will be removed since v3.0 |
73 | 74 | $registry = $container->get(JobRegistry::class); |
74 | 75 | $registry->setHandler(MailQueue::JOB_NAME, \Spiral\SendIt\Jobs\MailJobAdapter::class); |
@@ -76,20 +77,27 @@ discard block |
||
76 | 77 | |
77 | 78 | $container->bindSingleton( |
78 | 79 | MailerInterface::class, |
79 | - static function (MailerConfig $config) use ($container) { |
|
80 | - if ($config->getQueueConnection() === 'sync') { |
|
80 | + static function (MailerConfig $config) use ($container) |
|
81 | + { |
|
82 | + if ($config->getQueueConnection() === 'sync') |
|
83 | + { |
|
81 | 84 | $queue = $container->get(ShortCircuit::class); |
82 | - } else { |
|
85 | + } |
|
86 | + else |
|
87 | + { |
|
83 | 88 | $queue = $container->get(QueueInterface::class); |
84 | 89 | } |
85 | 90 | |
86 | 91 | return new MailQueue($config, $queue); |
87 | 92 | } |
88 | 93 | ); |
89 | - } else { |
|
94 | + } |
|
95 | + else |
|
96 | + { |
|
90 | 97 | $container->bindSingleton( |
91 | 98 | MailerInterface::class, |
92 | - static function (MailerConfig $config, QueueConnectionProviderInterface $provider) { |
|
99 | + static function (MailerConfig $config, QueueConnectionProviderInterface $provider) |
|
100 | + { |
|
93 | 101 | return new MailQueue( |
94 | 102 | $config, |
95 | 103 | $provider->getConnection($config->getQueueConnection()) |
@@ -98,7 +106,8 @@ discard block |
||
98 | 106 | ); |
99 | 107 | } |
100 | 108 | |
101 | - if ($container->has(HandlerRegistryInterface::class)) { |
|
109 | + if ($container->has(HandlerRegistryInterface::class)) |
|
110 | + { |
|
102 | 111 | $registry = $container->get(HandlerRegistryInterface::class); |
103 | 112 | $registry->setHandler(MailQueue::JOB_NAME, \Spiral\SendIt\MailJob::class); |
104 | 113 | } |