@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct( |
15 | 15 | private readonly ?string $domain = null, |
16 | 16 | private readonly bool $secure = false |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | bool $httpOnly = true, |
74 | 74 | ?string $sameSite = null |
75 | 75 | ): self { |
76 | - if (\is_null($domain)) { |
|
76 | + if (\is_null($domain)){ |
|
77 | 77 | //Let's resolve domain via config |
78 | 78 | $domain = $this->domain; |
79 | 79 | } |
80 | 80 | |
81 | - if (\is_null($secure)) { |
|
81 | + if (\is_null($secure)){ |
|
82 | 82 | $secure = $this->secure; |
83 | 83 | } |
84 | 84 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function delete(string $name): void |
104 | 104 | { |
105 | - foreach ($this->scheduled as $index => $cookie) { |
|
106 | - if ($cookie->getName() === $name) { |
|
105 | + foreach ($this->scheduled as $index => $cookie){ |
|
106 | + if ($cookie->getName() === $name){ |
|
107 | 107 | unset($this->scheduled[$index]); |
108 | 108 | } |
109 | 109 | } |
@@ -73,12 +73,14 @@ discard block |
||
73 | 73 | bool $httpOnly = true, |
74 | 74 | ?string $sameSite = null |
75 | 75 | ): self { |
76 | - if (\is_null($domain)) { |
|
76 | + if (\is_null($domain)) |
|
77 | + { |
|
77 | 78 | //Let's resolve domain via config |
78 | 79 | $domain = $this->domain; |
79 | 80 | } |
80 | 81 | |
81 | - if (\is_null($secure)) { |
|
82 | + if (\is_null($secure)) |
|
83 | + { |
|
82 | 84 | $secure = $this->secure; |
83 | 85 | } |
84 | 86 | |
@@ -102,8 +104,10 @@ discard block |
||
102 | 104 | */ |
103 | 105 | public function delete(string $name): void |
104 | 106 | { |
105 | - foreach ($this->scheduled as $index => $cookie) { |
|
106 | - if ($cookie->getName() === $name) { |
|
107 | + foreach ($this->scheduled as $index => $cookie) |
|
108 | + { |
|
109 | + if ($cookie->getName() === $name) |
|
110 | + { |
|
107 | 111 | unset($this->scheduled[$index]); |
108 | 112 | } |
109 | 113 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public function __construct( |
26 | 26 | private readonly CookiesConfig $config, |
27 | 27 | private readonly EncryptionInterface $encryption |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function process(Request $request, RequestHandlerInterface $handler): Response |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | { |
51 | 51 | $cookies = $request->getCookieParams(); |
52 | 52 | |
53 | - foreach ($cookies as $name => $cookie) { |
|
54 | - if (!$this->isProtected($name)) { |
|
53 | + foreach ($cookies as $name => $cookie){ |
|
54 | + if (!$this->isProtected($name)){ |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | protected function isProtected(string $cookie): bool |
68 | 68 | { |
69 | - if (\in_array($cookie, $this->config->getExcludedCookies(), true)) { |
|
69 | + if (\in_array($cookie, $this->config->getExcludedCookies(), true)){ |
|
70 | 70 | //Excluded |
71 | 71 | return false; |
72 | 72 | } |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function packCookies(Response $response, CookieQueue $queue): Response |
83 | 83 | { |
84 | - if (empty($queue->getScheduled())) { |
|
84 | + if (empty($queue->getScheduled())){ |
|
85 | 85 | return $response; |
86 | 86 | } |
87 | 87 | |
88 | 88 | $cookies = $response->getHeader('Set-Cookie'); |
89 | 89 | |
90 | - foreach ($queue->getScheduled() as $cookie) { |
|
91 | - if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())) { |
|
90 | + foreach ($queue->getScheduled() as $cookie){ |
|
91 | + if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())){ |
|
92 | 92 | $cookies[] = $cookie->createHeader(); |
93 | 93 | continue; |
94 | 94 | } |
@@ -99,28 +99,28 @@ discard block |
||
99 | 99 | return $response->withHeader('Set-Cookie', $cookies); |
100 | 100 | } |
101 | 101 | |
102 | - private function decodeCookie(array|string $cookie): mixed |
|
102 | + private function decodeCookie(array | string $cookie): mixed |
|
103 | 103 | { |
104 | - try { |
|
105 | - if (\is_array($cookie)) { |
|
106 | - return \array_map(fn (array|string $cookie) => $this->decodeCookie($cookie), $cookie); |
|
104 | + try{ |
|
105 | + if (\is_array($cookie)){ |
|
106 | + return \array_map(fn (array | string $cookie) => $this->decodeCookie($cookie), $cookie); |
|
107 | 107 | } |
108 | - } catch (DecryptException) { |
|
108 | + }catch (DecryptException){ |
|
109 | 109 | return null; |
110 | 110 | } |
111 | 111 | |
112 | - switch ($this->config->getProtectionMethod()) { |
|
112 | + switch ($this->config->getProtectionMethod()){ |
|
113 | 113 | case CookiesConfig::COOKIE_ENCRYPT: |
114 | - try { |
|
114 | + try{ |
|
115 | 115 | return $this->encryption->getEncrypter()->decrypt($cookie); |
116 | - } catch (DecryptException) { |
|
116 | + }catch (DecryptException){ |
|
117 | 117 | } |
118 | 118 | return null; |
119 | 119 | case CookiesConfig::COOKIE_HMAC: |
120 | 120 | $hmac = \substr($cookie, -1 * CookiesConfig::MAC_LENGTH); |
121 | 121 | $value = \substr($cookie, 0, \strlen($cookie) - \strlen($hmac)); |
122 | 122 | |
123 | - if (\hash_equals($this->hmacSign($value), $hmac)) { |
|
123 | + if (\hash_equals($this->hmacSign($value), $hmac)){ |
|
124 | 124 | return $value; |
125 | 125 | } |
126 | 126 | } |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | private function encodeCookie(Cookie $cookie): Cookie |
144 | 144 | { |
145 | 145 | $value = $cookie->getValue() ?? ''; |
146 | - if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT) { |
|
146 | + if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT){ |
|
147 | 147 | $encryptor = $this->encryption->getEncrypter(); |
148 | 148 | |
149 | 149 | return $cookie->withValue($encryptor->encrypt($value)); |
150 | 150 | } |
151 | 151 | |
152 | 152 | //VALUE.HMAC |
153 | - return $cookie->withValue($value . $this->hmacSign($value)); |
|
153 | + return $cookie->withValue($value.$this->hmacSign($value)); |
|
154 | 154 | } |
155 | 155 | } |
@@ -50,8 +50,10 @@ discard block |
||
50 | 50 | { |
51 | 51 | $cookies = $request->getCookieParams(); |
52 | 52 | |
53 | - foreach ($cookies as $name => $cookie) { |
|
54 | - if (!$this->isProtected($name)) { |
|
53 | + foreach ($cookies as $name => $cookie) |
|
54 | + { |
|
55 | + if (!$this->isProtected($name)) |
|
56 | + { |
|
55 | 57 | continue; |
56 | 58 | } |
57 | 59 | |
@@ -66,7 +68,8 @@ discard block |
||
66 | 68 | */ |
67 | 69 | protected function isProtected(string $cookie): bool |
68 | 70 | { |
69 | - if (\in_array($cookie, $this->config->getExcludedCookies(), true)) { |
|
71 | + if (\in_array($cookie, $this->config->getExcludedCookies(), true)) |
|
72 | + { |
|
70 | 73 | //Excluded |
71 | 74 | return false; |
72 | 75 | } |
@@ -81,14 +84,17 @@ discard block |
||
81 | 84 | */ |
82 | 85 | protected function packCookies(Response $response, CookieQueue $queue): Response |
83 | 86 | { |
84 | - if (empty($queue->getScheduled())) { |
|
87 | + if (empty($queue->getScheduled())) |
|
88 | + { |
|
85 | 89 | return $response; |
86 | 90 | } |
87 | 91 | |
88 | 92 | $cookies = $response->getHeader('Set-Cookie'); |
89 | 93 | |
90 | - foreach ($queue->getScheduled() as $cookie) { |
|
91 | - if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())) { |
|
94 | + foreach ($queue->getScheduled() as $cookie) |
|
95 | + { |
|
96 | + if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())) |
|
97 | + { |
|
92 | 98 | $cookies[] = $cookie->createHeader(); |
93 | 99 | continue; |
94 | 100 | } |
@@ -101,26 +107,35 @@ discard block |
||
101 | 107 | |
102 | 108 | private function decodeCookie(array|string $cookie): mixed |
103 | 109 | { |
104 | - try { |
|
105 | - if (\is_array($cookie)) { |
|
110 | + try |
|
111 | + { |
|
112 | + if (\is_array($cookie)) |
|
113 | + { |
|
106 | 114 | return \array_map(fn (array|string $cookie) => $this->decodeCookie($cookie), $cookie); |
107 | 115 | } |
108 | - } catch (DecryptException) { |
|
116 | + } |
|
117 | + catch (DecryptException) |
|
118 | + { |
|
109 | 119 | return null; |
110 | 120 | } |
111 | 121 | |
112 | - switch ($this->config->getProtectionMethod()) { |
|
122 | + switch ($this->config->getProtectionMethod()) |
|
123 | + { |
|
113 | 124 | case CookiesConfig::COOKIE_ENCRYPT: |
114 | - try { |
|
125 | + try |
|
126 | + { |
|
115 | 127 | return $this->encryption->getEncrypter()->decrypt($cookie); |
116 | - } catch (DecryptException) { |
|
128 | + } |
|
129 | + catch (DecryptException) |
|
130 | + { |
|
117 | 131 | } |
118 | 132 | return null; |
119 | 133 | case CookiesConfig::COOKIE_HMAC: |
120 | 134 | $hmac = \substr($cookie, -1 * CookiesConfig::MAC_LENGTH); |
121 | 135 | $value = \substr($cookie, 0, \strlen($cookie) - \strlen($hmac)); |
122 | 136 | |
123 | - if (\hash_equals($this->hmacSign($value), $hmac)) { |
|
137 | + if (\hash_equals($this->hmacSign($value), $hmac)) |
|
138 | + { |
|
124 | 139 | return $value; |
125 | 140 | } |
126 | 141 | } |
@@ -143,7 +158,8 @@ discard block |
||
143 | 158 | private function encodeCookie(Cookie $cookie): Cookie |
144 | 159 | { |
145 | 160 | $value = $cookie->getValue() ?? ''; |
146 | - if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT) { |
|
161 | + if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT) |
|
162 | + { |
|
147 | 163 | $encryptor = $this->encryption->getEncrypter(); |
148 | 164 | |
149 | 165 | return $cookie->withValue($encryptor->encrypt($value)); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | private readonly bool $secure = false, |
63 | 63 | private readonly bool $httpOnly = true, |
64 | 64 | ?string $sameSite = null |
65 | - ) { |
|
65 | + ){ |
|
66 | 66 | $this->sameSite = new Cookie\SameSite($sameSite, $secure); |
67 | 67 | } |
68 | 68 | |
@@ -158,30 +158,30 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function createHeader(): string |
160 | 160 | { |
161 | - $header = [\rawurlencode($this->name) . '=' . \rawurlencode((string)$this->value)]; |
|
161 | + $header = [\rawurlencode($this->name).'='.\rawurlencode((string)$this->value)]; |
|
162 | 162 | |
163 | - if ($this->lifetime !== null) { |
|
164 | - $header[] = 'Expires=' . \gmdate(\DateTime::COOKIE, $this->getExpires()); |
|
163 | + if ($this->lifetime !== null){ |
|
164 | + $header[] = 'Expires='.\gmdate(\DateTime::COOKIE, $this->getExpires()); |
|
165 | 165 | $header[] = \sprintf('Max-Age=%d', $this->lifetime); |
166 | 166 | } |
167 | 167 | |
168 | - if (!empty($this->path)) { |
|
168 | + if (!empty($this->path)){ |
|
169 | 169 | $header[] = \sprintf('Path=%s', $this->path); |
170 | 170 | } |
171 | 171 | |
172 | - if (!empty($this->domain)) { |
|
172 | + if (!empty($this->domain)){ |
|
173 | 173 | $header[] = \sprintf('Domain=%s', $this->domain); |
174 | 174 | } |
175 | 175 | |
176 | - if ($this->secure) { |
|
176 | + if ($this->secure){ |
|
177 | 177 | $header[] = 'Secure'; |
178 | 178 | } |
179 | 179 | |
180 | - if ($this->httpOnly) { |
|
180 | + if ($this->httpOnly){ |
|
181 | 181 | $header[] = 'HttpOnly'; |
182 | 182 | } |
183 | 183 | |
184 | - if ($this->sameSite->get() !== null) { |
|
184 | + if ($this->sameSite->get() !== null){ |
|
185 | 185 | $header[] = \sprintf('SameSite=%s', $this->sameSite->get()); |
186 | 186 | } |
187 | 187 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function getExpires(): ?int |
197 | 197 | { |
198 | - if ($this->lifetime === null) { |
|
198 | + if ($this->lifetime === null){ |
|
199 | 199 | return null; |
200 | 200 | } |
201 | 201 |
@@ -160,28 +160,34 @@ discard block |
||
160 | 160 | { |
161 | 161 | $header = [\rawurlencode($this->name) . '=' . \rawurlencode((string)$this->value)]; |
162 | 162 | |
163 | - if ($this->lifetime !== null) { |
|
163 | + if ($this->lifetime !== null) |
|
164 | + { |
|
164 | 165 | $header[] = 'Expires=' . \gmdate(\DateTime::COOKIE, $this->getExpires()); |
165 | 166 | $header[] = \sprintf('Max-Age=%d', $this->lifetime); |
166 | 167 | } |
167 | 168 | |
168 | - if (!empty($this->path)) { |
|
169 | + if (!empty($this->path)) |
|
170 | + { |
|
169 | 171 | $header[] = \sprintf('Path=%s', $this->path); |
170 | 172 | } |
171 | 173 | |
172 | - if (!empty($this->domain)) { |
|
174 | + if (!empty($this->domain)) |
|
175 | + { |
|
173 | 176 | $header[] = \sprintf('Domain=%s', $this->domain); |
174 | 177 | } |
175 | 178 | |
176 | - if ($this->secure) { |
|
179 | + if ($this->secure) |
|
180 | + { |
|
177 | 181 | $header[] = 'Secure'; |
178 | 182 | } |
179 | 183 | |
180 | - if ($this->httpOnly) { |
|
184 | + if ($this->httpOnly) |
|
185 | + { |
|
181 | 186 | $header[] = 'HttpOnly'; |
182 | 187 | } |
183 | 188 | |
184 | - if ($this->sameSite->get() !== null) { |
|
189 | + if ($this->sameSite->get() !== null) |
|
190 | + { |
|
185 | 191 | $header[] = \sprintf('SameSite=%s', $this->sameSite->get()); |
186 | 192 | } |
187 | 193 | |
@@ -195,7 +201,8 @@ discard block |
||
195 | 201 | */ |
196 | 202 | public function getExpires(): ?int |
197 | 203 | { |
198 | - if ($this->lifetime === null) { |
|
204 | + if ($this->lifetime === null) |
|
205 | + { |
|
199 | 206 | return null; |
200 | 207 | } |
201 | 208 |
@@ -178,7 +178,7 @@ |
||
178 | 178 | $request = m::mock(ServerRequestInterface::class); |
179 | 179 | $handler = m::mock(RequestHandlerInterface::class); |
180 | 180 | $dispatcher = m::mock(EventDispatcherInterface::class); |
181 | - $dispatcher->shouldReceive('dispatch')->once()->withArgs(function (Authorized $event) { |
|
181 | + $dispatcher->shouldReceive('dispatch')->once()->withArgs(function (Authorized $event){ |
|
182 | 182 | return $event->status->success === true |
183 | 183 | && $event->status->topics === null |
184 | 184 | && $event->status->response === null; |
@@ -150,7 +150,8 @@ discard block |
||
150 | 150 | $handler = m::mock(RequestHandlerInterface::class); |
151 | 151 | $dispatcher = m::mock(EventDispatcherInterface::class); |
152 | 152 | $status = new AuthorizationStatus($authStatus, ['topic_name'], ['foo' => 'bar']); |
153 | - $dispatcher->shouldReceive('dispatch')->once()->withArgs(function (Authorized $e) use($event, $status) { |
|
153 | + $dispatcher->shouldReceive('dispatch')->once()->withArgs(function (Authorized $e) use($event, $status) |
|
154 | + { |
|
154 | 155 | return $e->status === $status && $e::class === $event; |
155 | 156 | }); |
156 | 157 | |
@@ -178,7 +179,8 @@ discard block |
||
178 | 179 | $request = m::mock(ServerRequestInterface::class); |
179 | 180 | $handler = m::mock(RequestHandlerInterface::class); |
180 | 181 | $dispatcher = m::mock(EventDispatcherInterface::class); |
181 | - $dispatcher->shouldReceive('dispatch')->once()->withArgs(function (Authorized $event) { |
|
182 | + $dispatcher->shouldReceive('dispatch')->once()->withArgs(function (Authorized $event) |
|
183 | + { |
|
182 | 184 | return $event->status->success === true |
183 | 185 | && $event->status->topics === null |
184 | 186 | && $event->status->response === null; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct(array $topics = []) |
12 | 12 | { |
13 | - foreach ($topics as $topic => $callback) { |
|
13 | + foreach ($topics as $topic => $callback){ |
|
14 | 14 | $this->register($topic, $callback); |
15 | 15 | } |
16 | 16 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | |
23 | 23 | public function findCallback(string $topic, array &$matches): ?callable |
24 | 24 | { |
25 | - foreach ($this->patterns as $pattern => $callback) { |
|
26 | - if (\preg_match($pattern, $topic, $matches)) { |
|
25 | + foreach ($this->patterns as $pattern => $callback){ |
|
26 | + if (\preg_match($pattern, $topic, $matches)){ |
|
27 | 27 | return $callback; |
28 | 28 | } |
29 | 29 | } |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | private function compilePattern(string $topic): string |
35 | 35 | { |
36 | 36 | $replaces = []; |
37 | - if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
37 | + if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){ |
|
38 | 38 | $variables = \array_combine($matches[1], $matches[2]); |
39 | - foreach ($variables as $key => $_) { |
|
40 | - $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
|
39 | + foreach ($variables as $key => $_){ |
|
40 | + $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)'; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - return '/^' . \strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu'; |
|
44 | + return '/^'.\strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu'; |
|
45 | 45 | } |
46 | 46 | } |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct(array $topics = []) |
12 | 12 | { |
13 | - foreach ($topics as $topic => $callback) { |
|
13 | + foreach ($topics as $topic => $callback) |
|
14 | + { |
|
14 | 15 | $this->register($topic, $callback); |
15 | 16 | } |
16 | 17 | } |
@@ -22,8 +23,10 @@ discard block |
||
22 | 23 | |
23 | 24 | public function findCallback(string $topic, array &$matches): ?callable |
24 | 25 | { |
25 | - foreach ($this->patterns as $pattern => $callback) { |
|
26 | - if (\preg_match($pattern, $topic, $matches)) { |
|
26 | + foreach ($this->patterns as $pattern => $callback) |
|
27 | + { |
|
28 | + if (\preg_match($pattern, $topic, $matches)) |
|
29 | + { |
|
27 | 30 | return $callback; |
28 | 31 | } |
29 | 32 | } |
@@ -34,9 +37,11 @@ discard block |
||
34 | 37 | private function compilePattern(string $topic): string |
35 | 38 | { |
36 | 39 | $replaces = []; |
37 | - if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
40 | + if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) |
|
41 | + { |
|
38 | 42 | $variables = \array_combine($matches[1], $matches[2]); |
39 | - foreach ($variables as $key => $_) { |
|
43 | + foreach ($variables as $key => $_) |
|
44 | + { |
|
40 | 45 | $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
41 | 46 | } |
42 | 47 | } |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getDefaultConnection(): string |
55 | 55 | { |
56 | - if (empty($this->config['default'])) { |
|
56 | + if (empty($this->config['default'])){ |
|
57 | 57 | throw new InvalidArgumentException('Default broadcast connection is not defined.'); |
58 | 58 | } |
59 | 59 | |
60 | - if (!\is_string($this->config['default'])) { |
|
60 | + if (!\is_string($this->config['default'])){ |
|
61 | 61 | throw new InvalidArgumentException('Default broadcast connection config value must be a string'); |
62 | 62 | } |
63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public function getConnectionConfig(string $name): array |
68 | 68 | { |
69 | - if (!isset($this->config['connections'][$name])) { |
|
69 | + if (!isset($this->config['connections'][$name])){ |
|
70 | 70 | throw new InvalidArgumentException( |
71 | 71 | \sprintf('Config for connection `%s` is not defined.', $name) |
72 | 72 | ); |
@@ -74,19 +74,19 @@ discard block |
||
74 | 74 | |
75 | 75 | $config = $this->config['connections'][$name]; |
76 | 76 | |
77 | - if (!isset($config['driver'])) { |
|
77 | + if (!isset($config['driver'])){ |
|
78 | 78 | throw new InvalidArgumentException( |
79 | 79 | \sprintf('Driver for `%s` connection is not defined.', $name) |
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
83 | - if (!\is_string($config['driver'])) { |
|
83 | + if (!\is_string($config['driver'])){ |
|
84 | 84 | throw new InvalidArgumentException( |
85 | 85 | \sprintf('Driver value for `%s` connection must be a string', $name) |
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
89 | - if (isset($this->config['driverAliases'][$config['driver']])) { |
|
89 | + if (isset($this->config['driverAliases'][$config['driver']])){ |
|
90 | 90 | $config['driver'] = $this->config['driverAliases'][$config['driver']]; |
91 | 91 | } |
92 | 92 |
@@ -53,11 +53,13 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getDefaultConnection(): string |
55 | 55 | { |
56 | - if (empty($this->config['default'])) { |
|
56 | + if (empty($this->config['default'])) |
|
57 | + { |
|
57 | 58 | throw new InvalidArgumentException('Default broadcast connection is not defined.'); |
58 | 59 | } |
59 | 60 | |
60 | - if (!\is_string($this->config['default'])) { |
|
61 | + if (!\is_string($this->config['default'])) |
|
62 | + { |
|
61 | 63 | throw new InvalidArgumentException('Default broadcast connection config value must be a string'); |
62 | 64 | } |
63 | 65 | |
@@ -66,7 +68,8 @@ discard block |
||
66 | 68 | |
67 | 69 | public function getConnectionConfig(string $name): array |
68 | 70 | { |
69 | - if (!isset($this->config['connections'][$name])) { |
|
71 | + if (!isset($this->config['connections'][$name])) |
|
72 | + { |
|
70 | 73 | throw new InvalidArgumentException( |
71 | 74 | \sprintf('Config for connection `%s` is not defined.', $name) |
72 | 75 | ); |
@@ -74,19 +77,22 @@ discard block |
||
74 | 77 | |
75 | 78 | $config = $this->config['connections'][$name]; |
76 | 79 | |
77 | - if (!isset($config['driver'])) { |
|
80 | + if (!isset($config['driver'])) |
|
81 | + { |
|
78 | 82 | throw new InvalidArgumentException( |
79 | 83 | \sprintf('Driver for `%s` connection is not defined.', $name) |
80 | 84 | ); |
81 | 85 | } |
82 | 86 | |
83 | - if (!\is_string($config['driver'])) { |
|
87 | + if (!\is_string($config['driver'])) |
|
88 | + { |
|
84 | 89 | throw new InvalidArgumentException( |
85 | 90 | \sprintf('Driver value for `%s` connection must be a string', $name) |
86 | 91 | ); |
87 | 92 | } |
88 | 93 | |
89 | - if (isset($this->config['driverAliases'][$config['driver']])) { |
|
94 | + if (isset($this->config['driverAliases'][$config['driver']])) |
|
95 | + { |
|
90 | 96 | $config['driver'] = $this->config['driverAliases'][$config['driver']]; |
91 | 97 | } |
92 | 98 |
@@ -12,6 +12,6 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | public AuthorizationStatus $status, |
14 | 14 | public readonly ServerRequestInterface $request |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | final class NullBroadcast implements BroadcastInterface |
10 | 10 | { |
11 | - public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void |
|
11 | + public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void |
|
12 | 12 | { |
13 | 13 | // Do nothing |
14 | 14 | } |
@@ -12,17 +12,17 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | private readonly LoggerInterface $logger, |
14 | 14 | private readonly string $level = LogLevel::INFO |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | - public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void |
|
18 | + public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void |
|
19 | 19 | { |
20 | 20 | $topics = \implode(', ', $this->formatTopics($this->toArray($topics))); |
21 | 21 | |
22 | 22 | /** @var string $message */ |
23 | - foreach ($this->toArray($messages) as $message) { |
|
23 | + foreach ($this->toArray($messages) as $message){ |
|
24 | 24 | \assert(\is_string($message), 'Message argument must be a type of string'); |
25 | - $this->logger->log($this->level, 'Broadcasting on channels [' . $topics . '] with payload: ' . $message); |
|
25 | + $this->logger->log($this->level, 'Broadcasting on channels ['.$topics.'] with payload: '.$message); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -20,7 +20,8 @@ |
||
20 | 20 | $topics = \implode(', ', $this->formatTopics($this->toArray($topics))); |
21 | 21 | |
22 | 22 | /** @var string $message */ |
23 | - foreach ($this->toArray($messages) as $message) { |
|
23 | + foreach ($this->toArray($messages) as $message) |
|
24 | + { |
|
24 | 25 | \assert(\is_string($message), 'Message argument must be a type of string'); |
25 | 26 | $this->logger->log($this->level, 'Broadcasting on channels [' . $topics . '] with payload: ' . $message); |
26 | 27 | } |