Passed
Push — master ( ecaac2...a03751 )
by David
01:36
created
src/Calculator/FastCalculator.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
             // Walk every item in the PlaceArray and if I find one equal I use that as strating point
23 23
             foreach ($arrayNodes as $key => $node) {
24
-                if ( $node === $startingPoint ) {
24
+                if ($node === $startingPoint) {
25 25
                     $arrayNodeKey = $key;
26 26
                     break;
27 27
                 }
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 
35 35
             /** @var int $nodeWeight */
36 36
             foreach ($matrix[$arrayNodeKey] as $key => $nodeWeight) {
37
-                if( $key == $arrayNodeKey )
37
+                if ($key == $arrayNodeKey)
38 38
                     continue;
39 39
 
40
-                if( $minimumFound > $nodeWeight ){
40
+                if ($minimumFound > $nodeWeight) {
41 41
                     $minimumFound = $nodeWeight;
42 42
                     $minimumFoundKey = $key;
43 43
                 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@
 block discarded – undo
34 34
 
35 35
             /** @var int $nodeWeight */
36 36
             foreach ($matrix[$arrayNodeKey] as $key => $nodeWeight) {
37
-                if( $key == $arrayNodeKey )
38
-                    continue;
37
+                if( $key == $arrayNodeKey ) {
38
+                                    continue;
39
+                }
39 40
 
40 41
                 if( $minimumFound > $nodeWeight ){
41 42
                     $minimumFound = $nodeWeight;
Please login to merge, or discard this patch.
src/Entity/Place.php 2 patches
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -96,8 +96,9 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function setLeftRef(Place &$leftRef): Place
98 98
     {
99
-        if( $this->leftRef )
100
-            return $this;
99
+        if( $this->leftRef ) {
100
+                    return $this;
101
+        }
101 102
 
102 103
         $this->leftRef = $leftRef;
103 104
         $leftRef->setRightRef($this);
@@ -111,8 +112,9 @@  discard block
 block discarded – undo
111 112
      */
112 113
     public function setRightRef(Place &$rightRef): Place
113 114
     {
114
-        if( $this->rightRef )
115
-            return $this;
115
+        if( $this->rightRef ) {
116
+                    return $this;
117
+        }
116 118
 
117 119
         $this->rightRef = $rightRef;
118 120
         $rightRef->setLeftRef($this);
@@ -126,8 +128,9 @@  discard block
 block discarded – undo
126 128
      */
127 129
     public function setTopRef(Place &$topRef): Place
128 130
     {
129
-        if( $this->topRef )
130
-            return $this;
131
+        if( $this->topRef ) {
132
+                    return $this;
133
+        }
131 134
 
132 135
         $this->topRef = $topRef;
133 136
         $topRef->setBottomRef($this);
@@ -141,8 +144,9 @@  discard block
 block discarded – undo
141 144
      */
142 145
     public function setBottomRef(Place &$bottomRef): Place
143 146
     {
144
-        if( $this->bottomRef )
145
-            return $this;
147
+        if( $this->bottomRef ) {
148
+                    return $this;
149
+        }
146 150
 
147 151
         $this->bottomRef = $bottomRef;
148 152
         $bottomRef->setTopRef($this);
@@ -204,8 +208,9 @@  discard block
 block discarded – undo
204 208
     public function getWalkableNeighbors()
205 209
     {
206 210
         return array_filter($this->getNeighbors(), function($place) {
207
-            if( !$place )
208
-                return false;
211
+            if( !$place ) {
212
+                            return false;
213
+            }
209 214
 
210 215
             return $place->isWalkable();
211 216
         });
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
     public function __toString()
82 82
     {
83
-        return $this->getName() . "-" . $this->getOriginalWeight();
83
+        return $this->getName()."-".$this->getOriginalWeight();
84 84
     }
85 85
 
86 86
     /**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function setLeftRef(Place &$leftRef): Place
98 98
     {
99
-        if( $this->leftRef )
99
+        if ($this->leftRef)
100 100
             return $this;
101 101
 
102 102
         $this->leftRef = $leftRef;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function setRightRef(Place &$rightRef): Place
113 113
     {
114
-        if( $this->rightRef )
114
+        if ($this->rightRef)
115 115
             return $this;
116 116
 
117 117
         $this->rightRef = $rightRef;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function setTopRef(Place &$topRef): Place
128 128
     {
129
-        if( $this->topRef )
129
+        if ($this->topRef)
130 130
             return $this;
131 131
 
132 132
         $this->topRef = $topRef;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function setBottomRef(Place &$bottomRef): Place
143 143
     {
144
-        if( $this->bottomRef )
144
+        if ($this->bottomRef)
145 145
             return $this;
146 146
 
147 147
         $this->bottomRef = $bottomRef;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     public function getWalkableNeighbors()
205 205
     {
206 206
         return array_filter($this->getNeighbors(), function($place) {
207
-            if( !$place )
207
+            if (!$place)
208 208
                 return false;
209 209
 
210 210
             return $place->isWalkable();
Please login to merge, or discard this patch.
bin/warehouse.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@  discard block
 block discarded – undo
3 3
 use GGGGino\WarehousePath\Tools\Console\ConsoleRunner;
4 4
 use Symfony\Component\Console\Helper\HelperSet;
5 5
 
6
-$files       = [__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'];
6
+$files       = [__DIR__.'/../vendor/autoload.php', __DIR__.'/../../../autoload.php'];
7 7
 $loader      = null;
8 8
 $cwd         = getcwd();
9
-$directories = [$cwd, $cwd . DIRECTORY_SEPARATOR . 'config'];
9
+$directories = [$cwd, $cwd.DIRECTORY_SEPARATOR.'config'];
10 10
 $configFile  = null;
11 11
 
12 12
 foreach ($files as $file) {
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
     }
18 18
 }
19 19
 
20
-if (! $loader) {
20
+if (!$loader) {
21 21
     throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
22 22
 }
23 23
 
24
-$commands  = [];
24
+$commands = [];
25 25
 
26 26
 ConsoleRunner::run($commands);
Please login to merge, or discard this patch.
src/Parser/MatrixParser.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,17 +45,17 @@
 block discarded – undo
45 45
      */
46 46
     public function parse()
47 47
     {
48
-        foreach($this->originalMatrix as $rKey => $row) {
49
-            foreach($row as $cKey => $column) {
48
+        foreach ($this->originalMatrix as $rKey => $row) {
49
+            foreach ($row as $cKey => $column) {
50 50
                 $placeType = $this->placeCollector->getPlaceTypeByWeight($column['weight']);
51 51
                 $placeTypeNew = new Place($placeType);
52 52
 
53
-                $placeTypeNew->setName($rKey . $cKey);
54
-                if( isset($this->originalMatrix[$rKey - 1][$cKey]['obj']) ) {
53
+                $placeTypeNew->setName($rKey.$cKey);
54
+                if (isset($this->originalMatrix[$rKey - 1][$cKey]['obj'])) {
55 55
                     $placeTypeNew->setTopRef($this->originalMatrix[$rKey - 1][$cKey]['obj']);
56 56
                 }
57 57
 
58
-                if( isset($this->originalMatrix[$rKey][$cKey - 1]['obj']) ) {
58
+                if (isset($this->originalMatrix[$rKey][$cKey - 1]['obj'])) {
59 59
                     $placeTypeNew->setLeftRef($this->originalMatrix[$rKey][$cKey - 1]['obj']);
60 60
                 }
61 61
 
Please login to merge, or discard this patch.
src/Warehouse.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public static function createFromJson($path)
53 53
     {
54
-        if( !$path )
54
+        if (!$path)
55 55
             throw new \Exception('Please select a path');
56 56
 
57 57
         $placesCollector = new PlacesCollector();
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public static function createFromMatrix($param)
76 76
     {
77
-        if( !is_array($param) )
77
+        if (!is_array($param))
78 78
             throw new \Exception('Matrix should be initialized with an array');
79 79
 
80 80
         $placesCollector = new PlacesCollector();
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public static function createFromTree($param)
99 99
     {
100
-        if( !is_array($param) )
100
+        if (!is_array($param))
101 101
             throw new \Exception('Should be initialized with an array');
102 102
 
103 103
         $placesCollector = new PlacesCollector();
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
         /** @var Place[][] $resultMatrix */
179 179
         $resultMatrix = array();
180 180
 
181
-        if ( empty($places) )
181
+        if (empty($places))
182 182
             throw new \Exception('First add the places');
183 183
 
184 184
         /** @var Place $startingPlace */
185 185
         $startingPlace = reset($places);
186 186
 
187
-        while ( $newPlace = $startingPlace->getTopRef() ) {
187
+        while ($newPlace = $startingPlace->getTopRef()) {
188 188
             $startingPlace = $newPlace;
189 189
         }
190 190
 
191
-        while ( $newPlace = $startingPlace->getLeftRef() ) {
191
+        while ($newPlace = $startingPlace->getLeftRef()) {
192 192
             $startingPlace = $newPlace;
193 193
         }
194 194
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public static function createFromJson($path)
53 53
     {
54
-        if( !$path )
55
-            throw new \Exception('Please select a path');
54
+        if( !$path ) {
55
+                    throw new \Exception('Please select a path');
56
+        }
56 57
 
57 58
         $placesCollector = new PlacesCollector();
58 59
         $placesCollector->addBasePlaceTypes();
@@ -74,8 +75,9 @@  discard block
 block discarded – undo
74 75
      */
75 76
     public static function createFromMatrix($param)
76 77
     {
77
-        if( !is_array($param) )
78
-            throw new \Exception('Matrix should be initialized with an array');
78
+        if( !is_array($param) ) {
79
+                    throw new \Exception('Matrix should be initialized with an array');
80
+        }
79 81
 
80 82
         $placesCollector = new PlacesCollector();
81 83
         $placesCollector->addBasePlaceTypes();
@@ -97,8 +99,9 @@  discard block
 block discarded – undo
97 99
      */
98 100
     public static function createFromTree($param)
99 101
     {
100
-        if( !is_array($param) )
101
-            throw new \Exception('Should be initialized with an array');
102
+        if( !is_array($param) ) {
103
+                    throw new \Exception('Should be initialized with an array');
104
+        }
102 105
 
103 106
         $placesCollector = new PlacesCollector();
104 107
         $placesCollector->addBasePlaceTypes();
@@ -178,8 +181,9 @@  discard block
 block discarded – undo
178 181
         /** @var Place[][] $resultMatrix */
179 182
         $resultMatrix = array();
180 183
 
181
-        if ( empty($places) )
182
-            throw new \Exception('First add the places');
184
+        if ( empty($places) ) {
185
+                    throw new \Exception('First add the places');
186
+        }
183 187
 
184 188
         /** @var Place $startingPlace */
185 189
         $startingPlace = reset($places);
Please login to merge, or discard this patch.
src/Breadcrumb/BreadthFirstBreadcrumb.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function createBreadcrumb(Place $startPlace, Place $endPlace = null)
52 52
     {
53
-        if ( is_callable( $this->onPreCreateBreadcumb ) ) {
53
+        if (is_callable($this->onPreCreateBreadcumb)) {
54 54
             call_user_func($this->onPreCreateBreadcumb, $startPlace, $this->placeCollector->getPlacesType());
55 55
         }
56 56
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             /** @var Place $current */
62 62
             $current = array_shift($frontier);
63 63
 
64
-            if ( is_callable( $this->onWalk ) ) {
64
+            if (is_callable($this->onWalk)) {
65 65
                 call_user_func($this->onWalk, $current);
66 66
             }
67 67
 
Please login to merge, or discard this patch.
src/Tools/Console/Command/GraphicalTestCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     protected function execute(InputInterface $input, OutputInterface $output)
32 32
     {
33
-        $warehouse = Warehouse::createFromJson(getcwd() . "/resources/biggerWarehouse.json");
33
+        $warehouse = Warehouse::createFromJson(getcwd()."/resources/biggerWarehouse.json");
34 34
 
35 35
         /** @var Place $nodeStart */
36 36
         $nodeStart = $warehouse->getPlacesCollector()->getPlaces()[5];
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
         $table->setRows($calculatedMatrix);
46 46
         $table->render();
47 47
 
48
-        $output->writeln("Start: " . $nodeStart->getName());
49
-        $output->writeln("End: " . $nodeEnd->getName());
50
-        $output->writeln("Total path: " . $nodeEnd->getCurrentWeight());
48
+        $output->writeln("Start: ".$nodeStart->getName());
49
+        $output->writeln("End: ".$nodeEnd->getName());
50
+        $output->writeln("Total path: ".$nodeEnd->getCurrentWeight());
51 51
     }
52 52
 }
Please login to merge, or discard this patch.
src/Tools/Console/Command/ShortestPathGraphicalTestCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     protected function execute(InputInterface $input, OutputInterface $output)
33 33
     {
34 34
         /** @var Warehouse $warehouse */
35
-        $warehouse = Warehouse::createFromJson(getcwd() . "/../resources/biggerWarehouse.json");
35
+        $warehouse = Warehouse::createFromJson(getcwd()."/../resources/biggerWarehouse.json");
36 36
         $calculatedArray = $warehouse->getPlacesCollector()->getPlaces();
37 37
 
38 38
         $warehouse->setPathCalculator(new ShortPathCalculator());
Please login to merge, or discard this patch.
src/Tools/Console/Command/PrintMatrixTestCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     protected function execute(InputInterface $input, OutputInterface $output)
32 32
     {
33 33
         /** @var Warehouse $warehouse */
34
-        $warehouse = Warehouse::createFromJson(getcwd() . "/./resources/simpleWarehouse.json");
34
+        $warehouse = Warehouse::createFromJson(getcwd()."/./resources/simpleWarehouse.json");
35 35
 
36 36
         $this->printTable($output, array(), $warehouse->createMatrix());
37 37
     }
Please login to merge, or discard this patch.