Passed
Pull Request — master (#660)
by butschster
07:38
created
src/Broadcasting/src/Bootloader/WebsocketsBootloader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@
 block discarded – undo
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 24
             $http->addMiddleware(AuthorizationMiddleware::class);
24 25
         }
25 26
     }
Please login to merge, or discard this patch.
src/Broadcasting/src/BroadcastManager.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,8 @@
 block discarded – undo
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 35
             return $this->connections[$name];
35 36
         }
36 37
 
Please login to merge, or discard this patch.
src/Broadcasting/src/Middleware/AuthorizationMiddleware.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,11 +32,13 @@
 block discarded – undo
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 37
             return $handler->handle($request);
37 38
         }
38 39
 
39
-        if ($this->broadcast->authorize($request)) {
40
+        if ($this->broadcast->authorize($request))
41
+        {
40 42
             return $this->responseFactory->createResponse(200);
41 43
         }
42 44
 
Please login to merge, or discard this patch.
src/Broadcasting/src/Driver/LogBroadcast.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@
 block discarded – undo
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 26
             assert(\is_string($message), 'Message argument must be a type of string');
26 27
             $this->logger->info('Broadcasting on channels [' . $topics . '] with payload:' . PHP_EOL . $message);
27 28
         }
Please login to merge, or discard this patch.
src/Broadcasting/src/Driver/AbstractBroadcast.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
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 21
             return (string)$topic;
21 22
         }, $topics);
22 23
     }
@@ -28,7 +29,8 @@  discard block
 block discarded – undo
28 29
      */
29 30
     protected function toArray($entries): array
30 31
     {
31
-        switch (true) {
32
+        switch (true)
33
+        {
32 34
             case \is_array($entries):
33 35
                 return $entries;
34 36
 
Please login to merge, or discard this patch.
src/Broadcasting/src/Config/BroadcastConfig.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@  discard block
 block discarded – undo
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 32
             $this->patterns[$this->compilePattern($topic)] = $callback;
32 33
         }
33 34
     }
@@ -53,11 +54,13 @@  discard block
 block discarded – undo
53 54
      */
54 55
     public function getDefaultDriver(): string
55 56
     {
56
-        if (!isset($this->config['default']) || empty($this->config['default'])) {
57
+        if (!isset($this->config['default']) || empty($this->config['default']))
58
+        {
57 59
             throw new InvalidArgumentException('Default broadcast connection is not defined.');
58 60
         }
59 61
 
60
-        if (!\is_string($this->config['default'])) {
62
+        if (!\is_string($this->config['default']))
63
+        {
61 64
             throw new InvalidArgumentException('Default broadcast connection config value must be a string');
62 65
         }
63 66
 
@@ -66,7 +69,8 @@  discard block
 block discarded – undo
66 69
 
67 70
     public function getDriverConfig(string $name): array
68 71
     {
69
-        if (!isset($this->config['connections'][$name])) {
72
+        if (!isset($this->config['connections'][$name]))
73
+        {
70 74
             throw new InvalidArgumentException(
71 75
                 sprintf('Config for connection `%s` is not defined.', $name)
72 76
             );
@@ -74,19 +78,22 @@  discard block
 block discarded – undo
74 78
 
75 79
         $config = $this->config['connections'][$name];
76 80
 
77
-        if (!isset($config['driver'])) {
81
+        if (!isset($config['driver']))
82
+        {
78 83
             throw new InvalidArgumentException(
79 84
                 sprintf('Driver for `%s` connection is not defined.', $name)
80 85
             );
81 86
         }
82 87
 
83
-        if (!\is_string($config['driver'])) {
88
+        if (!\is_string($config['driver']))
89
+        {
84 90
             throw new InvalidArgumentException(
85 91
                 \sprintf('Driver value for `%s` connection must be a string', $name)
86 92
             );
87 93
         }
88 94
 
89
-        if (isset($this->config['driverAliases'][$config['driver']])) {
95
+        if (isset($this->config['driverAliases'][$config['driver']]))
96
+        {
90 97
             $config['driver'] = $this->config['driverAliases'][$config['driver']];
91 98
         }
92 99
 
@@ -95,8 +102,10 @@  discard block
 block discarded – undo
95 102
 
96 103
     public function findTopicCallback(string $topic, array &$matches): ?callable
97 104
     {
98
-        foreach ($this->patterns as $pattern => $callback) {
99
-            if (preg_match($pattern, $topic, $matches)) {
105
+        foreach ($this->patterns as $pattern => $callback)
106
+        {
107
+            if (preg_match($pattern, $topic, $matches))
108
+            {
100 109
                 return $callback;
101 110
             }
102 111
         }
@@ -107,9 +116,11 @@  discard block
 block discarded – undo
107 116
     private function compilePattern(string $topic): string
108 117
     {
109 118
         $replaces = [];
110
-        if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) {
119
+        if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches))
120
+        {
111 121
             $variables = array_combine($matches[1], $matches[2]);
112
-            foreach ($variables as $key => $_) {
122
+            foreach ($variables as $key => $_)
123
+            {
113 124
                 $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)';
114 125
             }
115 126
         }
Please login to merge, or discard this patch.