@@ -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 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | protected function formatTopics(array $topics): array |
| 18 | 18 | { |
| 19 | - return \array_map(fn (string|\Stringable $topic) => (string) $topic, $topics); |
|
| 19 | + return \array_map(fn (string | \Stringable $topic) => (string)$topic, $topics); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param iterable<T>|T $entries |
| 25 | 25 | * @return array<T> |
| 26 | 26 | */ |
| 27 | - protected function toArray(iterable|string|\Stringable $entries): array |
|
| 27 | + protected function toArray(iterable | string | \Stringable $entries): array |
|
| 28 | 28 | { |
| 29 | 29 | return match (true) { |
| 30 | 30 | \is_array($entries) => $entries, |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | |
| 28 | 28 | public function __construct( |
| 29 | 29 | private readonly ConfiguratorInterface $config |
| 30 | - ) { |
|
| 30 | + ){ |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function registerDriverAlias(string $driverClass, string $alias): void |