@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | public function __construct( |
| 19 | 19 | FactoryInterface $factory, |
| 20 | 20 | BroadcastConfig $config |
| 21 | - ) { |
|
| 21 | + ){ |
|
| 22 | 22 | $this->factory = $factory; |
| 23 | 23 | $this->config = $config; |
| 24 | 24 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | // Replaces alias with real storage name |
| 31 | 31 | $name = $this->config->getAliases()[$name] ?? $name; |
| 32 | 32 | |
| 33 | - if (isset($this->connections[$name])) { |
|
| 33 | + if (isset($this->connections[$name])){ |
|
| 34 | 34 | return $this->connections[$name]; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -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 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | parent::__construct($config); |
| 29 | 29 | |
| 30 | 30 | $topics = (array)($config['authorize']['topics'] ?? []); |
| 31 | - foreach ($topics as $topic => $callback) { |
|
| 31 | + foreach ($topics as $topic => $callback){ |
|
| 32 | 32 | $this->patterns[$this->compilePattern($topic)] = $callback; |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function getDefaultConnection(): string |
| 56 | 56 | { |
| 57 | - if (!isset($this->config['default']) || empty($this->config['default'])) { |
|
| 57 | + if (!isset($this->config['default']) || empty($this->config['default'])){ |
|
| 58 | 58 | throw new InvalidArgumentException('Default broadcast connection is not defined.'); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if (!\is_string($this->config['default'])) { |
|
| 61 | + if (!\is_string($this->config['default'])){ |
|
| 62 | 62 | throw new InvalidArgumentException('Default broadcast connection config value must be a string'); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | public function getConnectionConfig(string $name): array |
| 69 | 69 | { |
| 70 | - if (!isset($this->config['connections'][$name])) { |
|
| 70 | + if (!isset($this->config['connections'][$name])){ |
|
| 71 | 71 | throw new InvalidArgumentException( |
| 72 | 72 | sprintf('Config for connection `%s` is not defined.', $name) |
| 73 | 73 | ); |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $config = $this->config['connections'][$name]; |
| 77 | 77 | |
| 78 | - if (!isset($config['driver'])) { |
|
| 78 | + if (!isset($config['driver'])){ |
|
| 79 | 79 | throw new InvalidArgumentException( |
| 80 | 80 | sprintf('Driver for `%s` connection is not defined.', $name) |
| 81 | 81 | ); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (!\is_string($config['driver'])) { |
|
| 84 | + if (!\is_string($config['driver'])){ |
|
| 85 | 85 | throw new InvalidArgumentException( |
| 86 | 86 | \sprintf('Driver value for `%s` connection must be a string', $name) |
| 87 | 87 | ); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if (isset($this->config['driverAliases'][$config['driver']])) { |
|
| 90 | + if (isset($this->config['driverAliases'][$config['driver']])){ |
|
| 91 | 91 | $config['driver'] = $this->config['driverAliases'][$config['driver']]; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | public function findTopicCallback(string $topic, array &$matches): ?callable |
| 98 | 98 | { |
| 99 | - foreach ($this->patterns as $pattern => $callback) { |
|
| 100 | - if (preg_match($pattern, $topic, $matches)) { |
|
| 99 | + foreach ($this->patterns as $pattern => $callback){ |
|
| 100 | + if (preg_match($pattern, $topic, $matches)){ |
|
| 101 | 101 | return $callback; |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | private function compilePattern(string $topic): string |
| 109 | 109 | { |
| 110 | 110 | $replaces = []; |
| 111 | - if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
| 111 | + if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){ |
|
| 112 | 112 | $variables = array_combine($matches[1], $matches[2]); |
| 113 | - foreach ($variables as $key => $_) { |
|
| 114 | - $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
|
| 113 | + foreach ($variables as $key => $_){ |
|
| 114 | + $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)'; |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return '/^' . strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu'; |
|
| 118 | + return '/^'.strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu'; |
|
| 119 | 119 | } |
| 120 | 120 | } |
@@ -29,9 +29,9 @@ |
||
| 29 | 29 | $topics = implode(', ', $this->formatTopics($this->toArray($topics))); |
| 30 | 30 | |
| 31 | 31 | /** @var string $message */ |
| 32 | - foreach ($this->toArray($messages) as $message) { |
|
| 32 | + foreach ($this->toArray($messages) as $message){ |
|
| 33 | 33 | assert(\is_string($message), 'Message argument must be a type of string'); |
| 34 | - $this->logger->log($this->level, 'Broadcasting on channels [' . $topics . '] with payload: ' . $message); |
|
| 34 | + $this->logger->log($this->level, 'Broadcasting on channels ['.$topics.'] with payload: '.$message); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -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 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | BroadcastInterface $broadcast, |
| 24 | 24 | ResponseFactoryInterface $responseFactory, |
| 25 | 25 | ?string $authorizationPath = null |
| 26 | - ) { |
|
| 26 | + ){ |
|
| 27 | 27 | $this->responseFactory = $responseFactory; |
| 28 | 28 | $this->broadcast = $broadcast; |
| 29 | 29 | $this->authorizationPath = $authorizationPath; |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | ServerRequestInterface $request, |
| 34 | 34 | RequestHandlerInterface $handler |
| 35 | 35 | ): ResponseInterface { |
| 36 | - if ($request->getUri()->getPath() !== $this->authorizationPath) { |
|
| 36 | + if ($request->getUri()->getPath() !== $this->authorizationPath){ |
|
| 37 | 37 | return $handler->handle($request); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | if ( |
| 41 | 41 | !$this->broadcast instanceof GuardInterface |
| 42 | 42 | || $this->broadcast->authorize($request) |
| 43 | - ) { |
|
| 43 | + ){ |
|
| 44 | 44 | return $this->responseFactory->createResponse(200); |
| 45 | 45 | } |
| 46 | 46 | |