Completed
Push — master ( 6634cb...f6cba5 )
by Kacper
06:10
created
Network/Connector/TcpXmppConnector.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,13 +44,13 @@
 block discarded – undo
44 44
                 stream_context_set_option($stream, 'ssl', 'peer_name', $this->_host);
45 45
 
46 46
                 $stream = new TcpStream($stream, $this->_loop);
47
-                $this->emit('connect', [ $stream ]);
47
+                $this->emit('connect', [$stream]);
48 48
 
49 49
                 return $stream;
50 50
             }
51 51
         }
52 52
 
53
-        throw new \RuntimeException('Cannot connect to '.$this->_host);
53
+        throw new \RuntimeException('Cannot connect to ' . $this->_host);
54 54
     }
55 55
 
56 56
     public function __construct(string $host, LoopInterface $loop)
Please login to merge, or discard this patch.
Stanza/Presence.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function setShow(string $show = 'available')
71 71
     {
72
-        if(!in_array($show, self::POSSIBLE_SHOW)) {
72
+        if (!in_array($show, self::POSSIBLE_SHOW)) {
73 73
             throw new InvalidArgumentException(format('$show must be one of: {possible}. {show} given.', [
74 74
                 'possible' => implode(',', self::POSSIBLE_SHOW),
75 75
                 'show'     => $show
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         }
78 78
 
79 79
         $predicate = filter\element('show', 'jabber:client');
80
-        if(in_array($show, ['available', 'unavailable'])) {
80
+        if (in_array($show, ['available', 'unavailable'])) {
81 81
             $this->remove($predicate);
82 82
             $this->type = $show;
83 83
             return;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     public function setStatus(string $status = null)
100 100
     {
101 101
         $predicate = filter\element('status', 'jabber:client');
102
-        if($status === null) {
102
+        if ($status === null) {
103 103
             $this->remove($predicate);
104 104
             return;
105 105
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     public function setPriority(int $priority = null)
116 116
     {
117 117
         $predicate = filter\element('status', 'jabber:client');
118
-        if(!$priority) {
118
+        if (!$priority) {
119 119
             $this->remove($predicate);
120 120
         }
121 121
 
Please login to merge, or discard this patch.
Stanza/Stanza.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function getFrom()
57 57
     {
58
-        if((string)$this->_from !== $this->hasAttribute('from')) {
58
+        if ((string)$this->_from !== $this->hasAttribute('from')) {
59 59
             $this->_from = $this->hasAttribute('from') ? new Jid($this->getAttribute('from')) : null;
60 60
         }
61 61
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
     public function getTo()
66 66
     {
67
-        if((string)$this->_to !== $this->hasAttribute('to')) {
67
+        if ((string)$this->_to !== $this->hasAttribute('to')) {
68 68
             $this->_to = $this->hasAttribute('to') ? new Jid($this->getAttribute('to')) : null;
69 69
         }
70 70
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 
89 89
     public function setFrom($from)
90 90
     {
91
-        if($from instanceof Jid) {
91
+        if ($from instanceof Jid) {
92 92
             $this->_from = $from instanceof Jid ? $from : new Jid($from);
93 93
         }
94 94
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
     public function setTo($to)
99 99
     {
100
-        if($to instanceof Jid) {
100
+        if ($to instanceof Jid) {
101 101
             $this->_to = $to instanceof Jid ? $to : new Jid($to);
102 102
         }
103 103
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     public static function getXmlCollocations() : array
134 134
     {
135 135
         return [
136
-            [ Error::class, 'name' => 'error', 'uri' => 'jabber:client' ],
136
+            [Error::class, 'name' => 'error', 'uri' => 'jabber:client'],
137 137
         ];
138 138
     }
139 139
 }
Please login to merge, or discard this patch.
Stream/Features.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function __construct(array $features = [])
41 41
     {
42
-        parent::__construct('stream:features', XmlStream::NAMESPACE_URI, [ 'content' => $features ]);
42
+        parent::__construct('stream:features', XmlStream::NAMESPACE_URI, ['content' => $features]);
43 43
     }
44 44
 
45 45
     /**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
     public function getMechanisms()
54 54
     {
55
-        return array_map(function (XmlElement $element) {
55
+        return array_map(function(XmlElement $element) {
56 56
             return $element->innerXml;
57 57
         }, $this->get(filter\element\name('mechanisms'))->children ?? []);
58 58
     }
Please login to merge, or discard this patch.
Utils/filter.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function equals($value) : \Closure
36 36
 {
37
-    return function ($argument) use ($value) {
37
+    return function($argument) use ($value) {
38 38
         return $argument == $value;
39 39
     };
40 40
 }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function same($value) : \Closure
57 57
 {
58
-    return function ($argument) use ($value) {
58
+    return function($argument) use ($value) {
59 59
         return $argument === $value;
60 60
     };
61 61
 }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function instance($expected) : \Closure
79 79
 {
80
-    return function ($object) use ($expected) {
80
+    return function($object) use ($expected) {
81 81
         return $expected instanceof \Closure ? $expected(get_class($object)) : $object instanceof $expected;
82 82
     };
83 83
 }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
  */
104 104
 function matches($regex, ...$options) : \Closure
105 105
 {
106
-    return function ($value) use ($regex, $options) {
106
+    return function($value) use ($regex, $options) {
107 107
         return preg_match($regex, $value, $null, ...$options) > 0;
108 108
     };
109 109
 }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
  * @return \Closure
123 123
  */
124 124
 function in(...$options) {
125
-    return function ($value) use ($options) {
125
+    return function($value) use ($options) {
126 126
         return in_array($value, $options);
127 127
     };
128 128
 }
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
  */
143 143
 function contains($value)
144 144
 {
145
-    if($value instanceof \Closure) {
146
-        return function (array $array) use ($value) {
145
+    if ($value instanceof \Closure) {
146
+        return function(array $array) use ($value) {
147 147
             foreach ($array as $item) {
148
-                if($value($item)) {
148
+                if ($value($item)) {
149 149
                     return true;
150 150
                 }
151 151
             }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         };
155 155
     }
156 156
 
157
-    return function (array $array) use ($value) {
157
+    return function(array $array) use ($value) {
158 158
         return array_search($value, $array) !== false;
159 159
     };
160 160
 }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
  */
175 175
 function has($key)
176 176
 {
177
-    return function (array $array) use ($key) {
177
+    return function(array $array) use ($key) {
178 178
         return (contains($key))(array_keys($array));
179 179
     };
180 180
 }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
  */
249 249
 function all(callable ...$functions) : \Closure
250 250
 {
251
-    return function (...$args) use ($functions) {
251
+    return function(...$args) use ($functions) {
252 252
         foreach ($functions as $function) {
253 253
             if (!$function(...$args)) {
254 254
                 return false;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
  */
278 278
 function any(callable ...$functions) : \Closure
279 279
 {
280
-    return function (...$args) use ($functions) {
280
+    return function(...$args) use ($functions) {
281 281
         foreach ($functions as $function) {
282 282
             if ($function(...$args)) {
283 283
                 return true;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 function not($predicate) : \Closure
323 323
 {
324 324
     $predicate = predicate($predicate);
325
-    return function (...$arguments) use ($predicate) {
325
+    return function(...$arguments) use ($predicate) {
326 326
         return !$predicate(...$arguments);
327 327
     };
328 328
 }
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
  */
351 351
 function argument(int $offset, callable $predicate, $length = true) : \Closure
352 352
 {
353
-    if($length === true) {
353
+    if ($length === true) {
354 354
         $length = 1;
355
-    } elseif($length === false) {
355
+    } elseif ($length === false) {
356 356
         $length = null;
357 357
     }
358 358
 
359
-    return function (...$arguments) use ($predicate, $offset, $length) {
359
+    return function(...$arguments) use ($predicate, $offset, $length) {
360 360
         return $predicate(...array_slice($arguments, $offset, $length, false));
361 361
     };
362 362
 }
@@ -379,9 +379,9 @@  discard block
 block discarded – undo
379 379
  */
380 380
 function consecutive(callable ...$predicates)
381 381
 {
382
-    return function (...$arguments) use ($predicates) {
382
+    return function(...$arguments) use ($predicates) {
383 383
         foreach ($arguments as $index => $value) {
384
-            if(!$predicates[$index]($value)) {
384
+            if (!$predicates[$index]($value)) {
385 385
                 return false;
386 386
             }
387 387
         }
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 function property($name, $value) {
394 394
     $predicate = $value instanceof \Closure ? $value : \Kadet\Xmpp\Utils\filter\equals($value);
395 395
 
396
-    return function ($element) use ($name, $predicate) {
396
+    return function($element) use ($name, $predicate) {
397 397
         return $predicate($element->$name);
398 398
     };
399 399
 }
Please login to merge, or discard this patch.
Utils/helper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 function typeof($value) : string
27 27
 {
28 28
     if (is_object($value)) {
29
-        return "object of type ".get_class($value);
29
+        return "object of type " . get_class($value);
30 30
     } elseif (is_resource($value)) {
31
-        return get_resource_type($value).' resource';
31
+        return get_resource_type($value) . ' resource';
32 32
     }
33 33
 
34 34
     return gettype($value);
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 
37 37
 function partial(callable $callable, $argument, int $position = 0) : callable
38 38
 {
39
-    return function (...$arguments) use ($callable, $argument, $position) {
39
+    return function(...$arguments) use ($callable, $argument, $position) {
40 40
         $arguments = array_merge(
41 41
             array_slice($arguments, 0, $position),
42
-            [ $argument ],
42
+            [$argument],
43 43
             array_slice($arguments, $position)
44 44
         );
45 45
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 function dump($value)
51 51
 {
52
-    echo Dumper::get()->dump($value).PHP_EOL.PHP_EOL;
52
+    echo Dumper::get()->dump($value) . PHP_EOL . PHP_EOL;
53 53
 }
54 54
 
55 55
 function dd($value)
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
 function format($string, array $arguments = [])
62 62
 {
63
-    return str_replace(array_map(function ($e) { return "{{$e}}"; }, array_keys($arguments)), $arguments, $string);
63
+    return str_replace(array_map(function($e) { return "{{$e}}"; }, array_keys($arguments)), $arguments, $string);
64 64
 }
65 65
 
66 66
 function rearrange(array $array, array $keys) : array
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 function copy(array $array)
76 76
 {
77 77
     return array_map(function($element) {
78
-        if(is_array($element)) {
78
+        if (is_array($element)) {
79 79
             return copy($element);
80
-        } elseif(is_object($element)) {
80
+        } elseif (is_object($element)) {
81 81
             return clone $element;
82 82
         }
83 83
 
Please login to merge, or discard this patch.
Component/Binding.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
     {
32 32
         parent::setClient($client);
33 33
 
34
-        $client->on('features', function (Features $features) {
34
+        $client->on('features', function(Features $features) {
35 35
             return !$this->bind($features);
36 36
         });
37 37
     }
38 38
 
39 39
     public function bind(Features $features)
40 40
     {
41
-        if($features->has(with\element('bind', self::XMLNS))) {
41
+        if ($features->has(with\element('bind', self::XMLNS))) {
42 42
             $stanza = new Iq('set');
43 43
             $bind = $stanza->append(new Iq\Query(self::XMLNS, 'bind'));
44 44
 
45
-            if(!$this->_client->jid->isBare()) {
45
+            if (!$this->_client->jid->isBare()) {
46 46
                 $bind->append(new XmlElement('resource', null, ['content' => $this->_client->jid->resource]));
47 47
             }
48 48
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     public function handleResult(Iq $stanza)
61 61
     {
62
-        if($stanza->type === 'error') {
62
+        if ($stanza->type === 'error') {
63 63
             throw BindingException::fromError($this->_client->jid, $stanza->error);
64 64
         }
65 65
 
Please login to merge, or discard this patch.
Component/PingKeepAlive.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function enable()
57 57
     {
58
-        if($this->_interval) {
58
+        if ($this->_interval) {
59 59
             $this->_timer = $this->_client->connector->getLoop()->addPeriodicTimer($this->_interval, function() {
60 60
                 $this->keepAlive();
61 61
             });
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function disable()
69 69
     {
70
-        if($this->_timer) {
70
+        if ($this->_timer) {
71 71
             $this->_timer->cancel();
72 72
         }
73 73
 
Please login to merge, or discard this patch.
Component/SaslAuthenticator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     {
65 65
         parent::setClient($client);
66 66
 
67
-        $client->on('features', function (Features $features) {
67
+        $client->on('features', function(Features $features) {
68 68
             return !$this->auth($features);
69 69
         });
70 70
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         if (!empty($features->mechanisms)) {
75 75
             foreach ($features->mechanisms as $name) {
76
-                if($this->tryMechanism($name)) {
76
+                if ($this->tryMechanism($name)) {
77 77
                     return true;
78 78
                 }
79 79
             }
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
             $response = '';
118 118
         }
119 119
 
120
-        $callback = $this->_client->on('element', function (XmlElement $challenge) use ($mechanism) {
120
+        $callback = $this->_client->on('element', function(XmlElement $challenge) use ($mechanism) {
121 121
             $this->handleChallenge($challenge, $mechanism);
122 122
         }, with\element('challenge', self::XMLNS));
123 123
 
124
-        $this->_client->once('element', function (XmlElement $result) use ($callback) {
124
+        $this->_client->once('element', function(XmlElement $result) use ($callback) {
125 125
             $this->_client->removeListener('element', $callback);
126 126
             $this->handleAuthResult($result);
127 127
         }, $this->_resultPredicate());
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
     private function mechanismWithoutChallenge(AuthenticationInterface $mechanism)
133 133
     {
134
-        $this->_client->once('element', function (XmlElement $result) {
134
+        $this->_client->once('element', function(XmlElement $result) {
135 135
             $this->handleAuthResult($result);
136 136
         }, $this->_resultPredicate());
137 137
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     {
151 151
         // todo: handle different scenarios
152 152
         if ($result->localName === 'failure') {
153
-            throw new AuthenticationException('Unable to auth. '.trim($result->innerXml));
153
+            throw new AuthenticationException('Unable to auth. ' . trim($result->innerXml));
154 154
         }
155 155
 
156 156
         $this->_client->getLogger()->info('Successfully authorized as {name}.', ['name' => (string)$this->_client->jid]);
Please login to merge, or discard this patch.