Passed
Push — master ( 2c8815...d0e3c7 )
by Alexander
02:28
created
src/Collection/PrioritizedObjectList.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Weblabltd\Component\Util\Collection;
6 6
 
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * @var array
16 16
      */
17
-    private $objects = [];
17
+    private $objects = [ ];
18 18
     /**
19 19
      * @var array
20 20
      */
21
-    private $indexes = [];
21
+    private $indexes = [ ];
22 22
     /**
23 23
      * @var int
24 24
      */
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      *
45 45
      * @return PrioritizedObjectList
46 46
      */
47
-    public function add($object, ?int $priority = self::DEFAULT_PRIORITY): PrioritizedObjectList
47
+    public function add($object, ?int $priority = self::DEFAULT_PRIORITY) : PrioritizedObjectList
48 48
     {
49 49
         if (!is_object($object)) {
50 50
             throw new \InvalidArgumentException(
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 
61 61
         $index = spl_object_hash($object);
62 62
 
63
-        if (!isset($this->objects[$index])) {
64
-            $this->objects[$index] = [$object, [$priority ?? static::DEFAULT_PRIORITY, $this->serial--]];
65
-            $this->indexes[]       = $index;
63
+        if (!isset($this->objects[ $index ])) {
64
+            $this->objects[ $index ] = [ $object, [ $priority ?? static::DEFAULT_PRIORITY, $this->serial-- ] ];
65
+            $this->indexes[ ]       = $index;
66 66
         } else {
67 67
             // if object is present just override it's priority
68
-            $this->objects[$index][1][0] = $priority ?? static::DEFAULT_PRIORITY;
68
+            $this->objects[ $index ][ 1 ][ 0 ] = $priority ?? static::DEFAULT_PRIORITY;
69 69
         }
70 70
 
71 71
         // mark as not sorted
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
     {
90 90
         $this->sort();
91 91
 
92
-        if (!isset($this->indexes[$this->cursor])) {
92
+        if (!isset($this->indexes[ $this->cursor ])) {
93 93
             throw new \OutOfBoundsException('There is no object at the current position');
94 94
         }
95 95
 
96
-        return $this->objects[$this->indexes[$this->cursor]][0];
96
+        return $this->objects[ $this->indexes[ $this->cursor ] ][ 0 ];
97 97
     }
98 98
 
99 99
     /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $this->sort();
125 125
 
126
-        return isset($this->indexes[$this->cursor]);
126
+        return isset($this->indexes[ $this->cursor ]);
127 127
     }
128 128
 
129 129
     /**
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
             return;
146 146
         }
147 147
 
148
-        uasort($this->objects, function ($o1, $o2) {
149
-            return $o2[1][0] <=> $o1[1][0];
148
+        uasort($this->objects, function($o1, $o2) {
149
+            return $o2[ 1 ][ 0 ] <=> $o1[ 1 ][ 0 ];
150 150
         });
151 151
 
152 152
         $this->indexes = array_keys($this->objects);
Please login to merge, or discard this patch.