@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function start(HttpBootloader $http, BroadcastConfig $config): void |
| 21 | 21 | { |
| 22 | - if ($config->getAuthorizationPath() !== null) { |
|
| 22 | + if ($config->getAuthorizationPath() !== null){ |
|
| 23 | 23 | $http->addMiddleware(AuthorizationMiddleware::class); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | BroadcastInterface $broadcast, |
| 23 | 23 | BroadcastConfig $config, |
| 24 | 24 | ResponseFactoryInterface $responseFactory |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | $this->config = $config; |
| 27 | 27 | $this->responseFactory = $responseFactory; |
| 28 | 28 | $this->broadcast = $broadcast; |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | ServerRequestInterface $request, |
| 33 | 33 | RequestHandlerInterface $handler |
| 34 | 34 | ): ResponseInterface { |
| 35 | - if ($request->getUri()->getPath() !== $this->config->getAuthorizationPath()) { |
|
| 35 | + if ($request->getUri()->getPath() !== $this->config->getAuthorizationPath()){ |
|
| 36 | 36 | return $handler->handle($request); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ($this->broadcast->authorize($request)) { |
|
| 39 | + if ($this->broadcast->authorize($request)){ |
|
| 40 | 40 | return $this->responseFactory->createResponse(200); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | $topics = implode(', ', $this->formatTopics($topics)); |
| 22 | 22 | |
| 23 | 23 | /** @var string $message */ |
| 24 | - foreach ($this->toArray($messages) as $message) { |
|
| 24 | + foreach ($this->toArray($messages) as $message){ |
|
| 25 | 25 | assert(\is_string($message), 'Message argument must be a type of string'); |
| 26 | - $this->logger->info('Broadcasting on channels [' . $topics . '] with payload:' . PHP_EOL . $message); |
|
| 26 | + $this->logger->info('Broadcasting on channels ['.$topics.'] with payload:'.PHP_EOL.$message); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
@@ -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 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | parent::__construct($config); |
| 29 | 29 | |
| 30 | - foreach ($config['authorize']['topics'] as $topic => $callback) { |
|
| 30 | + foreach ($config['authorize']['topics'] as $topic => $callback){ |
|
| 31 | 31 | $this->patterns[$this->compilePattern($topic)] = $callback; |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function getDefaultDriver(): string |
| 55 | 55 | { |
| 56 | - if (!isset($this->config['default']) || empty($this->config['default'])) { |
|
| 56 | + if (!isset($this->config['default']) || 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 getDriverConfig(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 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | public function findTopicCallback(string $topic, array &$matches): ?callable |
| 97 | 97 | { |
| 98 | - foreach ($this->patterns as $pattern => $callback) { |
|
| 99 | - if (preg_match($pattern, $topic, $matches)) { |
|
| 98 | + foreach ($this->patterns as $pattern => $callback){ |
|
| 99 | + if (preg_match($pattern, $topic, $matches)){ |
|
| 100 | 100 | return $callback; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | private function compilePattern(string $topic): string |
| 108 | 108 | { |
| 109 | 109 | $replaces = []; |
| 110 | - if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
| 110 | + if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){ |
|
| 111 | 111 | $variables = array_combine($matches[1], $matches[2]); |
| 112 | - foreach ($variables as $key => $_) { |
|
| 113 | - $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
|
| 112 | + foreach ($variables as $key => $_){ |
|
| 113 | + $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)'; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - return '/^' . strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu'; |
|
| 117 | + return '/^'.strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu'; |
|
| 118 | 118 | } |
| 119 | 119 | } |