Completed
Push — master ( 10de85...76baec )
by Kacper
03:21
created
Stanza/Error.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function setType(string $type)
68 68
     {
69
-        if(!in_array($type, ['auth', 'cancel', 'continue', 'modify', 'wait'])) {
69
+        if (!in_array($type, ['auth', 'cancel', 'continue', 'modify', 'wait'])) {
70 70
             throw new InvalidArgumentException(
71 71
                 format("Error type must be 'auth', 'cancel', 'continue', 'modify' or 'wait', '{type}' given.", [
72 72
                     'type' => $type
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public function setText(string $text)
114 114
     {
115
-        if(!$this->text) {
115
+        if (!$this->text) {
116 116
             $this->append(new XmlElement('text', self::XMLNS));
117 117
         }
118 118
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
             !$condition instanceof XmlElement ? $this->_definedCondition($condition) : $condition
135 135
         ];
136 136
 
137
-        if($description !== null) {
137
+        if ($description !== null) {
138 138
             $content[] = new XmlElement('text', self::XMLNS, ['content' => $description]);
139 139
         }
140 140
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
     private function _definedCondition(string $condition) : XmlElement
147 147
     {
148
-        if(!in_array($condition, [
148
+        if (!in_array($condition, [
149 149
             'bad-request', 'conflict', 'feature-not-implemented', 'forbidden',
150 150
             'gone', 'internal-server-error', 'item-not-found', 'jid-malformed',
151 151
             'not-acceptable', 'not-allowed', 'not-authorized', 'policy-violation',
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
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function __construct(array $features = [])
40 40
     {
41
-        parent::__construct('stream:features', XmlStream::NAMESPACE_URI, [ 'content' => $features ]);
41
+        parent::__construct('stream:features', XmlStream::NAMESPACE_URI, ['content' => $features]);
42 42
     }
43 43
 
44 44
     /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
     public function getMechanisms()
53 53
     {
54
-        return array_map(function (XmlElement $element) {
54
+        return array_map(function(XmlElement $element) {
55 55
             return $element->innerXml;
56 56
         }, $this->get(\Kadet\Xmpp\Utils\filter\tag('mechanisms'))->children ?? []);
57 57
     }
Please login to merge, or discard this patch.
Xml/XmlElement.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function getInnerXml()
137 137
     {
138
-        return implode('', array_map(function ($element) {
138
+        return implode('', array_map(function($element) {
139 139
             if (is_string($element)) {
140 140
                 return htmlspecialchars($element);
141 141
             } elseif ($element instanceof XmlElement) {
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         $attributes = $this->attributes();
181 181
 
182 182
         $result = "<{$this->name}";
183
-        $result .= ' ' . implode(' ', array_map(function ($key, $value) {
183
+        $result .= ' ' . implode(' ', array_map(function($key, $value) {
184 184
             return $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"';
185 185
         }, array_keys($attributes), array_values($attributes)));
186 186
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function lookupPrefix(string $uri = null)
203 203
     {
204
-        return $this->getNamespaces()[ $uri ] ?? false;
204
+        return $this->getNamespaces()[$uri] ?? false;
205 205
     }
206 206
 
207 207
     /**
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
     {
246 246
         $attribute = $this->_prefix($attribute, $uri);
247 247
         if ($value === null) {
248
-            unset($this->_attributes[ $attribute ]);
248
+            unset($this->_attributes[$attribute]);
249 249
 
250 250
             return;
251 251
         }
252 252
 
253
-        $this->_attributes[ $attribute ] = $value;
253
+        $this->_attributes[$attribute] = $value;
254 254
     }
255 255
 
256 256
     /**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function getAttribute(string $attribute, string $uri = null)
264 264
     {
265
-        return $this->_attributes[ $this->_prefix($attribute, $uri) ] ?? false;
265
+        return $this->_attributes[$this->_prefix($attribute, $uri)] ?? false;
266 266
     }
267 267
 
268 268
     /**
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function hasAttribute(string $attribute, string $uri = null)
277 277
     {
278
-        return isset($this->_attributes[ $this->_prefix($attribute, $uri) ]);
278
+        return isset($this->_attributes[$this->_prefix($attribute, $uri)]);
279 279
     }
280 280
 
281 281
     /**
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public function getParents()
286 286
     {
287
-        return $this->_parent ? array_merge([ $this->_parent ], $this->_parent->getParents()) : [];
287
+        return $this->_parent ? array_merge([$this->_parent], $this->_parent->getParents()) : [];
288 288
     }
289 289
 
290 290
     /**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
     protected function setParent(XmlElement $parent)
304 304
     {
305 305
         if (!$this->_prefix && ($prefix = $parent->lookupPrefix($this->namespace)) !== false) {
306
-            $this->_namespaces[ $this->namespace ] = $prefix;
306
+            $this->_namespaces[$this->namespace] = $prefix;
307 307
             $this->_prefix                         = $prefix;
308 308
         }
309 309
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
             return false;
327 327
         }
328 328
 
329
-        if(is_array($element)) {
329
+        if (is_array($element)) {
330 330
             array_walk($element, [$this, 'append']);
331 331
             return $element;
332 332
         }
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             $prefix = $this->_prefix;
371 371
         }
372 372
 
373
-        $this->_namespaces[ $uri ] = $prefix;
373
+        $this->_namespaces[$uri] = $prefix;
374 374
     }
375 375
 
376 376
     public function getName()
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
      */
419 419
     public function element(string $name, string $uri = null, int $index = 0)
420 420
     {
421
-        return array_values($this->elements($name, $uri))[ $index ] ?? false;
421
+        return array_values($this->elements($name, $uri))[$index] ?? false;
422 422
     }
423 423
 
424 424
     /**
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
     private function attributes(): array
493 493
     {
494 494
         $namespaces = $this->getNamespaces(false);
495
-        $namespaces = array_map(function ($prefix, $uri) {
495
+        $namespaces = array_map(function($prefix, $uri) {
496 496
             return [$prefix ? "xmlns:{$prefix}" : 'xmlns', $uri];
497 497
         }, array_values($namespaces), array_keys($namespaces));
498 498
 
Please login to merge, or discard this patch.
Exception/Protocol/BindingException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@
 block discarded – undo
42 42
 
43 43
     private static function _conditionDescription(Error $error)
44 44
     {
45
-        if(!empty($error->text)) {
45
+        if (!empty($error->text)) {
46 46
             return $error->text;
47 47
         }
48 48
 
49 49
         return [
50 50
             'bad-request' => 'Bad Request: "{resource}" is not valid XMPP resource identifier.',
51 51
             'conflict'    => 'Conflict: {bare}/{resource} is already in use.'
52
-        ][$error->condition] ?? 'Unknown reason: '.$error->condition;
52
+        ][$error->condition] ?? 'Unknown reason: ' . $error->condition;
53 53
     }
54 54
 }
Please login to merge, or discard this patch.
Utils/Filter/element.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 {
42 42
     $predicate = $uri instanceof \Closure ? $uri : \Kadet\Xmpp\Utils\filter\same($uri);
43 43
 
44
-    return function ($element) use ($predicate) {
44
+    return function($element) use ($predicate) {
45 45
         if (!$element instanceof XmlElement) {
46 46
             return false;
47 47
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 {
75 75
     $predicate = $name instanceof \Closure ? $name : \Kadet\Xmpp\Utils\filter\same($name);
76 76
 
77
-    return function ($element) use ($predicate) {
77
+    return function($element) use ($predicate) {
78 78
         if (!$element instanceof XmlElement) {
79 79
             return false;
80 80
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 {
109 109
     $predicate = $value instanceof \Closure ? $value : \Kadet\Xmpp\Utils\filter\equals($value);
110 110
 
111
-    return function ($element) use ($name, $predicate) {
111
+    return function($element) use ($name, $predicate) {
112 112
         if (!$element instanceof XmlElement) {
113 113
             return false;
114 114
         }
Please login to merge, or discard this patch.
Module/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 Stanza('iq', ['attributes' => ['type' => 'set']]);
43 43
             $bind = $stanza->append(new XmlElement('bind', self::XMLNS));
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(Stanza $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.
Stanza/Stanza.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function getFrom()
55 55
     {
56
-        if((string)$this->_from !== $this->hasAttribute('from')) {
56
+        if ((string)$this->_from !== $this->hasAttribute('from')) {
57 57
             $this->_from = $this->hasAttribute('from') ? new Jid($this->_from) : null;
58 58
         }
59 59
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
     public function getTo()
64 64
     {
65
-        if((string)$this->_to !== $this->hasAttribute('to')) {
65
+        if ((string)$this->_to !== $this->hasAttribute('to')) {
66 66
             $this->_to = $this->hasAttribute('to') ? new Jid($this->_to) : null;
67 67
         }
68 68
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
     public function setFrom($from)
88 88
     {
89
-        if($from instanceof Jid) {
89
+        if ($from instanceof Jid) {
90 90
             $this->_from = $from instanceof Jid ? $from : new Jid($from);
91 91
         }
92 92
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
     public function setTo($to)
97 97
     {
98
-        if($to instanceof Jid) {
98
+        if ($to instanceof Jid) {
99 99
             $this->_to = $to instanceof Jid ? $to : new Jid($to);
100 100
         }
101 101
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     public static function getXmlCollocations() : array
132 132
     {
133 133
         return [
134
-            [ Error::class, 'name' => 'error', 'uri' => 'jabber:client' ],
134
+            [Error::class, 'name' => 'error', 'uri' => 'jabber:client'],
135 135
         ];
136 136
     }
137 137
 }
Please login to merge, or discard this patch.
Xml/XmlParser.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
         xml_parser_set_option($this->_parser, XML_OPTION_SKIP_WHITE, 1);
72 72
         xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, 0);
73 73
 
74
-        xml_set_element_handler($this->_parser, function ($parser, $name, $attrs) {
74
+        xml_set_element_handler($this->_parser, function($parser, $name, $attrs) {
75 75
             $this->handleElementStart($name, $attrs);
76
-        }, function () {
76
+        }, function() {
77 77
             $this->handleElementEnd();
78 78
         });
79 79
 
80
-        xml_set_character_data_handler($this->_parser, function ($parser, $data) {
80
+        xml_set_character_data_handler($this->_parser, function($parser, $data) {
81 81
             $this->handleTextData($data);
82 82
         });
83 83
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
             return 'http://www.w3.org/2000/xmlns/';
112 112
         }
113 113
 
114
-        if (isset($namespaces[ $prefix ])) {
115
-            return $namespaces[ $prefix ];
114
+        if (isset($namespaces[$prefix])) {
115
+            return $namespaces[$prefix];
116 116
         }
117 117
 
118 118
         return !empty($this->_stack) ? end($this->_stack)->lookupUri($prefix) : null;
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
         list($attributes, $namespaces) = $this->_attributes($attrs);
124 124
         list($tag, $prefix)            = XmlElement::resolve($name);
125 125
 
126
-        $uri   = $this->_lookup($prefix, $namespaces);
126
+        $uri = $this->_lookup($prefix, $namespaces);
127 127
 
128 128
         /** @var XmlElement $element */
129
-        $element = $this->factory->create($uri, $tag, [ $name, $uri ], $this->_getCollocations());
129
+        $element = $this->factory->create($uri, $tag, [$name, $uri], $this->_getCollocations());
130 130
 
131 131
         foreach ($namespaces as $prefix => $uri) {
132 132
             $element->setNamespace($uri, $prefix);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     private function _getCollocations()
142 142
     {
143
-        if(empty($this->_stack)) {
143
+        if (empty($this->_stack)) {
144 144
             return [];
145 145
         }
146 146
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         if (count($this->_stack) > 0) {
160 160
             end($this->_stack)->append($element);
161 161
         }
162
-        $this->emit('parse.begin', [ $element, count($this->_stack) ]);
162
+        $this->emit('parse.begin', [$element, count($this->_stack)]);
163 163
 
164 164
         $this->_stack[] = $element;
165 165
     }
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 
173 173
         $element = array_pop($this->_stack);
174 174
         if (count($this->_stack) == 1) {
175
-            $this->emit('element', [ $element, count($this->_stack) ]);
175
+            $this->emit('element', [$element, count($this->_stack)]);
176 176
         }
177 177
 
178
-        $this->emit('parse.end', [ $element, count($this->_stack) ]);
178
+        $this->emit('parse.end', [$element, count($this->_stack)]);
179 179
     }
180 180
 
181 181
     private function handleTextData($data)
Please login to merge, or discard this patch.
XmppClient.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 
132 132
         $this->applyOptions($options);
133 133
 
134
-        $this->on('element', function (Features $element) {
134
+        $this->on('element', function(Features $element) {
135 135
             $this->_features = $element;
136 136
             $this->emit('features', [$element]);
137 137
         }, Features::class);
138 138
 
139
-        $this->on('close', function (Features $element) {
139
+        $this->on('close', function(Features $element) {
140 140
             $this->state = 'disconnected';
141 141
         }, Features::class);
142 142
     }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         $this->state = 'bound';
197 197
 
198 198
         $queue = new ObservableCollection();
199
-        $queue->on('empty', function () {
199
+        $queue->on('empty', function() {
200 200
             $this->state = 'ready';
201 201
         });
202 202
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     //region Parser
245 245
     public function setParser(XmlParser $parser)
246 246
     {
247
-        if($this->state !== "disconnected") {
247
+        if ($this->state !== "disconnected") {
248 248
             throw new \BadMethodCallException('Parser can be changed only when client is disconnected.');
249 249
         }
250 250
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             ));
273 273
         }
274 274
 
275
-        $this->_connector->on('connect', function ($stream) {
275
+        $this->_connector->on('connect', function($stream) {
276 276
             return $this->handleConnect($stream);
277 277
         });
278 278
     }
Please login to merge, or discard this patch.