@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | private readonly TokenStorageInterface $tokenStorage, |
36 | 36 | private readonly TransportRegistry $transportRegistry, |
37 | 37 | private readonly ?EventDispatcherInterface $eventDispatcher = null, |
38 | - ) {} |
|
38 | + ){} |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @throws \Throwable |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | |
56 | 56 | private function initContext(Request $request, AuthContextInterface $authContext): AuthContextInterface |
57 | 57 | { |
58 | - foreach ($this->transportRegistry->getTransports() as $name => $transport) { |
|
58 | + foreach ($this->transportRegistry->getTransports() as $name => $transport){ |
|
59 | 59 | $tokenID = $transport->fetchToken($request); |
60 | - if ($tokenID === null) { |
|
60 | + if ($tokenID === null){ |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $token = $this->tokenStorage->load($tokenID); |
65 | - if ($token === null) { |
|
65 | + if ($token === null){ |
|
66 | 66 | continue; |
67 | 67 | } |
68 | 68 | |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | |
77 | 77 | private function closeContext(Request $request, Response $response, AuthContextInterface $authContext): Response |
78 | 78 | { |
79 | - if ($authContext->getToken() === null) { |
|
79 | + if ($authContext->getToken() === null){ |
|
80 | 80 | return $response; |
81 | 81 | } |
82 | 82 | |
83 | 83 | $transport = $this->transportRegistry->getTransport($authContext->getTransport()); |
84 | 84 | |
85 | - if ($authContext->isClosed()) { |
|
85 | + if ($authContext->isClosed()){ |
|
86 | 86 | $this->tokenStorage->delete($authContext->getToken()); |
87 | 87 | |
88 | 88 | return $transport->removeToken( |
@@ -35,7 +35,8 @@ discard block |
||
35 | 35 | private readonly TokenStorageInterface $tokenStorage, |
36 | 36 | private readonly TransportRegistry $transportRegistry, |
37 | 37 | private readonly ?EventDispatcherInterface $eventDispatcher = null, |
38 | - ) {} |
|
38 | + ) { |
|
39 | +} |
|
39 | 40 | |
40 | 41 | /** |
41 | 42 | * @throws \Throwable |
@@ -55,14 +56,17 @@ discard block |
||
55 | 56 | |
56 | 57 | private function initContext(Request $request, AuthContextInterface $authContext): AuthContextInterface |
57 | 58 | { |
58 | - foreach ($this->transportRegistry->getTransports() as $name => $transport) { |
|
59 | + foreach ($this->transportRegistry->getTransports() as $name => $transport) |
|
60 | + { |
|
59 | 61 | $tokenID = $transport->fetchToken($request); |
60 | - if ($tokenID === null) { |
|
62 | + if ($tokenID === null) |
|
63 | + { |
|
61 | 64 | continue; |
62 | 65 | } |
63 | 66 | |
64 | 67 | $token = $this->tokenStorage->load($tokenID); |
65 | - if ($token === null) { |
|
68 | + if ($token === null) |
|
69 | + { |
|
66 | 70 | continue; |
67 | 71 | } |
68 | 72 | |
@@ -76,13 +80,15 @@ discard block |
||
76 | 80 | |
77 | 81 | private function closeContext(Request $request, Response $response, AuthContextInterface $authContext): Response |
78 | 82 | { |
79 | - if ($authContext->getToken() === null) { |
|
83 | + if ($authContext->getToken() === null) |
|
84 | + { |
|
80 | 85 | return $response; |
81 | 86 | } |
82 | 87 | |
83 | 88 | $transport = $this->transportRegistry->getTransport($authContext->getTransport()); |
84 | 89 | |
85 | - if ($authContext->isClosed()) { |
|
90 | + if ($authContext->isClosed()) |
|
91 | + { |
|
86 | 92 | $this->tokenStorage->delete($authContext->getToken()); |
87 | 93 | |
88 | 94 | return $transport->removeToken( |
@@ -33,7 +33,7 @@ |
||
33 | 33 | TokenStorageInterface $tokenStorage, |
34 | 34 | TransportRegistry $transportRegistry, |
35 | 35 | ?EventDispatcherInterface $eventDispatcher = null, |
36 | - ) { |
|
36 | + ){ |
|
37 | 37 | $this->authMiddleware = new AuthMiddleware( |
38 | 38 | $scope, |
39 | 39 | $actorProvider, |
@@ -34,7 +34,7 @@ |
||
34 | 34 | TransportRegistry $transportRegistry, |
35 | 35 | ?EventDispatcherInterface $eventDispatcher = null, |
36 | 36 | ?string $storage = null, |
37 | - ) { |
|
37 | + ){ |
|
38 | 38 | $this->authMiddleware = new AuthTransportMiddleware( |
39 | 39 | $transportName, |
40 | 40 | $scope, |
@@ -4,4 +4,4 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Auth\Exception; |
6 | 6 | |
7 | -class TransportException extends AuthException {} |
|
7 | +class TransportException extends AuthException{} |
@@ -4,4 +4,6 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Auth\Exception; |
6 | 6 | |
7 | -class TransportException extends AuthException {} |
|
7 | +class TransportException extends AuthException |
|
8 | +{ |
|
9 | +} |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function register(): void |
44 | 44 | { |
45 | - if (self::$registered) { |
|
45 | + if (self::$registered){ |
|
46 | 46 | return; |
47 | 47 | } |
48 | 48 | |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * Check if given uri or stream has been allocated. |
56 | 56 | */ |
57 | - public static function has(StreamInterface|string $file): bool |
|
57 | + public static function has(StreamInterface | string $file): bool |
|
58 | 58 | { |
59 | - if ($file instanceof StreamInterface) { |
|
60 | - $file = 'spiral://' . \spl_object_hash($file); |
|
59 | + if ($file instanceof StreamInterface){ |
|
60 | + $file = 'spiral://'.\spl_object_hash($file); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | return isset(self::$uris[$file]); |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | public static function getResource(StreamInterface $stream) |
73 | 73 | { |
74 | 74 | $mode = null; |
75 | - if ($stream->isReadable()) { |
|
75 | + if ($stream->isReadable()){ |
|
76 | 76 | $mode = 'r'; |
77 | 77 | } |
78 | 78 | |
79 | - if ($stream->isWritable()) { |
|
79 | + if ($stream->isWritable()){ |
|
80 | 80 | $mode = !empty($mode) ? 'r+' : 'w'; |
81 | 81 | } |
82 | 82 | |
83 | - if (empty($mode)) { |
|
83 | + if (empty($mode)){ |
|
84 | 84 | throw new WrapperException('Stream is not available in read or write modes'); |
85 | 85 | } |
86 | 86 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | self::register(); |
96 | 96 | |
97 | - $uri = 'spiral://' . \spl_object_hash($stream); |
|
97 | + $uri = 'spiral://'.\spl_object_hash($stream); |
|
98 | 98 | self::$uris[$uri] = $stream; |
99 | 99 | |
100 | 100 | return $uri; |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param string|StreamInterface $file String uri or StreamInterface. |
108 | 108 | */ |
109 | - public static function release(StreamInterface|string $file): void |
|
109 | + public static function release(StreamInterface | string $file): void |
|
110 | 110 | { |
111 | - if ($file instanceof StreamInterface) { |
|
112 | - $file = 'spiral://' . \spl_object_hash($file); |
|
111 | + if ($file instanceof StreamInterface){ |
|
112 | + $file = 'spiral://'.\spl_object_hash($file); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | unset(self::$uris[$file]); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function stream_eof(): bool |
122 | 122 | { |
123 | - if ($this->stream === null) { |
|
123 | + if ($this->stream === null){ |
|
124 | 124 | throw new WrapperException('Stream is not opened.'); |
125 | 125 | } |
126 | 126 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool |
134 | 134 | { |
135 | - if (!isset(self::$uris[$path])) { |
|
135 | + if (!isset(self::$uris[$path])){ |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | /** |
148 | 148 | * Read data from StreamInterface. |
149 | 149 | */ |
150 | - public function stream_read(int $length): string|false |
|
150 | + public function stream_read(int $length): string | false |
|
151 | 151 | { |
152 | - if ($this->stream === null) { |
|
152 | + if ($this->stream === null){ |
|
153 | 153 | throw new WrapperException('Stream is not opened.'); |
154 | 154 | } |
155 | 155 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function stream_seek(int $offset, int $whence = SEEK_SET): bool |
163 | 163 | { |
164 | - if ($this->stream === null) { |
|
164 | + if ($this->stream === null){ |
|
165 | 165 | throw new WrapperException('Stream is not opened.'); |
166 | 166 | } |
167 | 167 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function stream_stat(): array |
181 | 181 | { |
182 | - if ($this->stream === null) { |
|
182 | + if ($this->stream === null){ |
|
183 | 183 | throw new WrapperException('Stream is not opened.'); |
184 | 184 | } |
185 | 185 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function stream_tell(): int |
193 | 193 | { |
194 | - if ($this->stream === null) { |
|
194 | + if ($this->stream === null){ |
|
195 | 195 | throw new WrapperException('Stream is not opened.'); |
196 | 196 | } |
197 | 197 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function stream_write(string $data): int |
207 | 207 | { |
208 | - if ($this->stream === null) { |
|
208 | + if ($this->stream === null){ |
|
209 | 209 | throw new WrapperException('Stream is not opened.'); |
210 | 210 | } |
211 | 211 | |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @see stat() |
219 | 219 | */ |
220 | - public function url_stat(string $path, int $flag): array|false |
|
220 | + public function url_stat(string $path, int $flag): array | false |
|
221 | 221 | { |
222 | - try { |
|
223 | - if (isset(self::$uris[$path])) { |
|
222 | + try{ |
|
223 | + if (isset(self::$uris[$path])){ |
|
224 | 224 | return $this->getStreamStats(self::$uris[$path]); |
225 | 225 | } |
226 | - } catch (\Throwable $e) { |
|
227 | - if (($flag & \STREAM_URL_STAT_QUIET) === \STREAM_URL_STAT_QUIET) { |
|
226 | + }catch (\Throwable $e){ |
|
227 | + if (($flag & \STREAM_URL_STAT_QUIET) === \STREAM_URL_STAT_QUIET){ |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | \trigger_error($e->getMessage(), \E_USER_ERROR); |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | private function getStreamStats(StreamInterface $stream): array |
240 | 240 | { |
241 | 241 | $mode = $this->mode; |
242 | - if (empty($mode)) { |
|
243 | - if ($stream->isReadable()) { |
|
242 | + if (empty($mode)){ |
|
243 | + if ($stream->isReadable()){ |
|
244 | 244 | $mode = 'r'; |
245 | 245 | } |
246 | 246 | |
247 | - if ($stream->isWritable()) { |
|
247 | + if ($stream->isWritable()){ |
|
248 | 248 | $mode = !empty($mode) ? 'r+' : 'w'; |
249 | 249 | } |
250 | 250 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | 'uid' => 0, |
258 | 258 | 'gid' => 0, |
259 | 259 | 'rdev' => 0, |
260 | - 'size' => (string) $stream->getSize(), |
|
260 | + 'size' => (string)$stream->getSize(), |
|
261 | 261 | 'atime' => 0, |
262 | 262 | 'mtime' => 0, |
263 | 263 | 'ctime' => 0, |
@@ -42,7 +42,8 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function register(): void |
44 | 44 | { |
45 | - if (self::$registered) { |
|
45 | + if (self::$registered) |
|
46 | + { |
|
46 | 47 | return; |
47 | 48 | } |
48 | 49 | |
@@ -56,7 +57,8 @@ discard block |
||
56 | 57 | */ |
57 | 58 | public static function has(StreamInterface|string $file): bool |
58 | 59 | { |
59 | - if ($file instanceof StreamInterface) { |
|
60 | + if ($file instanceof StreamInterface) |
|
61 | + { |
|
60 | 62 | $file = 'spiral://' . \spl_object_hash($file); |
61 | 63 | } |
62 | 64 | |
@@ -72,15 +74,18 @@ discard block |
||
72 | 74 | public static function getResource(StreamInterface $stream) |
73 | 75 | { |
74 | 76 | $mode = null; |
75 | - if ($stream->isReadable()) { |
|
77 | + if ($stream->isReadable()) |
|
78 | + { |
|
76 | 79 | $mode = 'r'; |
77 | 80 | } |
78 | 81 | |
79 | - if ($stream->isWritable()) { |
|
82 | + if ($stream->isWritable()) |
|
83 | + { |
|
80 | 84 | $mode = !empty($mode) ? 'r+' : 'w'; |
81 | 85 | } |
82 | 86 | |
83 | - if (empty($mode)) { |
|
87 | + if (empty($mode)) |
|
88 | + { |
|
84 | 89 | throw new WrapperException('Stream is not available in read or write modes'); |
85 | 90 | } |
86 | 91 | |
@@ -108,7 +113,8 @@ discard block |
||
108 | 113 | */ |
109 | 114 | public static function release(StreamInterface|string $file): void |
110 | 115 | { |
111 | - if ($file instanceof StreamInterface) { |
|
116 | + if ($file instanceof StreamInterface) |
|
117 | + { |
|
112 | 118 | $file = 'spiral://' . \spl_object_hash($file); |
113 | 119 | } |
114 | 120 | |
@@ -120,7 +126,8 @@ discard block |
||
120 | 126 | */ |
121 | 127 | public function stream_eof(): bool |
122 | 128 | { |
123 | - if ($this->stream === null) { |
|
129 | + if ($this->stream === null) |
|
130 | + { |
|
124 | 131 | throw new WrapperException('Stream is not opened.'); |
125 | 132 | } |
126 | 133 | |
@@ -132,7 +139,8 @@ discard block |
||
132 | 139 | */ |
133 | 140 | public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool |
134 | 141 | { |
135 | - if (!isset(self::$uris[$path])) { |
|
142 | + if (!isset(self::$uris[$path])) |
|
143 | + { |
|
136 | 144 | return false; |
137 | 145 | } |
138 | 146 | |
@@ -149,7 +157,8 @@ discard block |
||
149 | 157 | */ |
150 | 158 | public function stream_read(int $length): string|false |
151 | 159 | { |
152 | - if ($this->stream === null) { |
|
160 | + if ($this->stream === null) |
|
161 | + { |
|
153 | 162 | throw new WrapperException('Stream is not opened.'); |
154 | 163 | } |
155 | 164 | |
@@ -161,7 +170,8 @@ discard block |
||
161 | 170 | */ |
162 | 171 | public function stream_seek(int $offset, int $whence = SEEK_SET): bool |
163 | 172 | { |
164 | - if ($this->stream === null) { |
|
173 | + if ($this->stream === null) |
|
174 | + { |
|
165 | 175 | throw new WrapperException('Stream is not opened.'); |
166 | 176 | } |
167 | 177 | |
@@ -179,7 +189,8 @@ discard block |
||
179 | 189 | */ |
180 | 190 | public function stream_stat(): array |
181 | 191 | { |
182 | - if ($this->stream === null) { |
|
192 | + if ($this->stream === null) |
|
193 | + { |
|
183 | 194 | throw new WrapperException('Stream is not opened.'); |
184 | 195 | } |
185 | 196 | |
@@ -191,7 +202,8 @@ discard block |
||
191 | 202 | */ |
192 | 203 | public function stream_tell(): int |
193 | 204 | { |
194 | - if ($this->stream === null) { |
|
205 | + if ($this->stream === null) |
|
206 | + { |
|
195 | 207 | throw new WrapperException('Stream is not opened.'); |
196 | 208 | } |
197 | 209 | |
@@ -205,7 +217,8 @@ discard block |
||
205 | 217 | */ |
206 | 218 | public function stream_write(string $data): int |
207 | 219 | { |
208 | - if ($this->stream === null) { |
|
220 | + if ($this->stream === null) |
|
221 | + { |
|
209 | 222 | throw new WrapperException('Stream is not opened.'); |
210 | 223 | } |
211 | 224 | |
@@ -219,12 +232,17 @@ discard block |
||
219 | 232 | */ |
220 | 233 | public function url_stat(string $path, int $flag): array|false |
221 | 234 | { |
222 | - try { |
|
223 | - if (isset(self::$uris[$path])) { |
|
235 | + try |
|
236 | + { |
|
237 | + if (isset(self::$uris[$path])) |
|
238 | + { |
|
224 | 239 | return $this->getStreamStats(self::$uris[$path]); |
225 | 240 | } |
226 | - } catch (\Throwable $e) { |
|
227 | - if (($flag & \STREAM_URL_STAT_QUIET) === \STREAM_URL_STAT_QUIET) { |
|
241 | + } |
|
242 | + catch (\Throwable $e) |
|
243 | + { |
|
244 | + if (($flag & \STREAM_URL_STAT_QUIET) === \STREAM_URL_STAT_QUIET) |
|
245 | + { |
|
228 | 246 | return false; |
229 | 247 | } |
230 | 248 | \trigger_error($e->getMessage(), \E_USER_ERROR); |
@@ -239,12 +257,15 @@ discard block |
||
239 | 257 | private function getStreamStats(StreamInterface $stream): array |
240 | 258 | { |
241 | 259 | $mode = $this->mode; |
242 | - if (empty($mode)) { |
|
243 | - if ($stream->isReadable()) { |
|
260 | + if (empty($mode)) |
|
261 | + { |
|
262 | + if ($stream->isReadable()) |
|
263 | + { |
|
244 | 264 | $mode = 'r'; |
245 | 265 | } |
246 | 266 | |
247 | - if ($stream->isWritable()) { |
|
267 | + if ($stream->isWritable()) |
|
268 | + { |
|
248 | 269 | $mode = !empty($mode) ? 'r+' : 'w'; |
249 | 270 | } |
250 | 271 | } |
@@ -7,4 +7,4 @@ |
||
7 | 7 | /** |
8 | 8 | * StreamWrapper specific exception. |
9 | 9 | */ |
10 | -class WrapperException extends \RuntimeException {} |
|
10 | +class WrapperException extends \RuntimeException{} |
@@ -14,7 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | public function __construct( |
16 | 16 | private readonly LoggerInterface $logger, |
17 | - ) {} |
|
17 | + ){} |
|
18 | 18 | |
19 | 19 | public function onMessageSent(MessageSent $event): void |
20 | 20 | { |
@@ -14,7 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | public function __construct( |
16 | 16 | private readonly LoggerInterface $logger, |
17 | - ) {} |
|
17 | + ) { |
|
18 | +} |
|
18 | 19 | |
19 | 20 | public function onMessageSent(MessageSent $event): void |
20 | 21 | { |
@@ -17,13 +17,13 @@ |
||
17 | 17 | public function __construct( |
18 | 18 | private readonly MailerConfig $config, |
19 | 19 | private readonly QueueInterface $queue, |
20 | - ) {} |
|
20 | + ){} |
|
21 | 21 | |
22 | 22 | public function send(MessageInterface ...$message): void |
23 | 23 | { |
24 | 24 | $options = Options::onQueue($this->config->getQueue()); |
25 | 25 | |
26 | - foreach ($message as $msg) { |
|
26 | + foreach ($message as $msg){ |
|
27 | 27 | $this->queue->push( |
28 | 28 | self::JOB_NAME, |
29 | 29 | MessageSerializer::pack($msg), |
@@ -17,13 +17,15 @@ |
||
17 | 17 | public function __construct( |
18 | 18 | private readonly MailerConfig $config, |
19 | 19 | private readonly QueueInterface $queue, |
20 | - ) {} |
|
20 | + ) { |
|
21 | +} |
|
21 | 22 | |
22 | 23 | public function send(MessageInterface ...$message): void |
23 | 24 | { |
24 | 25 | $options = Options::onQueue($this->config->getQueue()); |
25 | 26 | |
26 | - foreach ($message as $msg) { |
|
27 | + foreach ($message as $msg) |
|
28 | + { |
|
27 | 29 | $this->queue->push( |
28 | 30 | self::JOB_NAME, |
29 | 31 | MessageSerializer::pack($msg), |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | private readonly SymfonyMailer $mailer, |
22 | 22 | private readonly RendererInterface $renderer, |
23 | 23 | private readonly ?EventDispatcherInterface $dispatcher = null, |
24 | - ) {} |
|
24 | + ){} |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @throws TransportExceptionInterface |
28 | 28 | * @throws InvalidArgumentException |
29 | 29 | */ |
30 | - public function handle(string $name, string $id, string|array $payload): void |
|
30 | + public function handle(string $name, string $id, string | array $payload): void |
|
31 | 31 | { |
32 | - if (\is_string($payload)) { |
|
32 | + if (\is_string($payload)){ |
|
33 | 33 | $payload = \json_decode($payload, true, 512, JSON_THROW_ON_ERROR); |
34 | 34 | } |
35 | 35 | |
36 | - if (!\is_array($payload)) { |
|
36 | + if (!\is_array($payload)){ |
|
37 | 37 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
38 | 38 | } |
39 | 39 | |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | |
42 | 42 | $email = $this->renderer->render($message); |
43 | 43 | |
44 | - if ($email->getFrom() === []) { |
|
44 | + if ($email->getFrom() === []){ |
|
45 | 45 | $email->from(Address::create($this->config->getFromAddress())); |
46 | 46 | } |
47 | 47 | |
48 | - try { |
|
48 | + try{ |
|
49 | 49 | $this->mailer->send($email); |
50 | - } catch (TransportExceptionInterface $e) { |
|
50 | + }catch (TransportExceptionInterface $e){ |
|
51 | 51 | $this->dispatcher?->dispatch(new MessageNotSent($email, $e)); |
52 | 52 | |
53 | 53 | throw $e; |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | private readonly SymfonyMailer $mailer, |
22 | 22 | private readonly RendererInterface $renderer, |
23 | 23 | private readonly ?EventDispatcherInterface $dispatcher = null, |
24 | - ) {} |
|
24 | + ) { |
|
25 | +} |
|
25 | 26 | |
26 | 27 | /** |
27 | 28 | * @throws TransportExceptionInterface |
@@ -29,11 +30,13 @@ discard block |
||
29 | 30 | */ |
30 | 31 | public function handle(string $name, string $id, string|array $payload): void |
31 | 32 | { |
32 | - if (\is_string($payload)) { |
|
33 | + if (\is_string($payload)) |
|
34 | + { |
|
33 | 35 | $payload = \json_decode($payload, true, 512, JSON_THROW_ON_ERROR); |
34 | 36 | } |
35 | 37 | |
36 | - if (!\is_array($payload)) { |
|
38 | + if (!\is_array($payload)) |
|
39 | + { |
|
37 | 40 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
38 | 41 | } |
39 | 42 | |
@@ -41,13 +44,17 @@ discard block |
||
41 | 44 | |
42 | 45 | $email = $this->renderer->render($message); |
43 | 46 | |
44 | - if ($email->getFrom() === []) { |
|
47 | + if ($email->getFrom() === []) |
|
48 | + { |
|
45 | 49 | $email->from(Address::create($this->config->getFromAddress())); |
46 | 50 | } |
47 | 51 | |
48 | - try { |
|
52 | + try |
|
53 | + { |
|
49 | 54 | $this->mailer->send($email); |
50 | - } catch (TransportExceptionInterface $e) { |
|
55 | + } |
|
56 | + catch (TransportExceptionInterface $e) |
|
57 | + { |
|
51 | 58 | $this->dispatcher?->dispatch(new MessageNotSent($email, $e)); |
52 | 59 | |
53 | 60 | throw $e; |