@@ -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 (!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 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 (!isset($this->config['default']) || empty($this->config['default'])) { |
|
| 56 | + if (!isset($this->config['default']) || 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 | |