@@ -34,8 +34,9 @@ |
||
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; |
@@ -44,8 +44,9 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function createFromJson($path) |
46 | 46 | { |
47 | - if( !$path ) |
|
48 | - throw new \Exception('Please select a path'); |
|
47 | + if( !$path ) { |
|
48 | + throw new \Exception('Please select a path'); |
|
49 | + } |
|
49 | 50 | |
50 | 51 | $placesCollector = new PlacesCollector(); |
51 | 52 | $placesCollector->addBasePlaceTypes(); |
@@ -65,8 +66,9 @@ discard block |
||
65 | 66 | */ |
66 | 67 | public static function createFromMatrix($param) |
67 | 68 | { |
68 | - if( !is_array($param) ) |
|
69 | - throw new \Exception('Matrix should be initialized with an array'); |
|
69 | + if( !is_array($param) ) { |
|
70 | + throw new \Exception('Matrix should be initialized with an array'); |
|
71 | + } |
|
70 | 72 | |
71 | 73 | $placesCollector = new PlacesCollector(); |
72 | 74 | $placesCollector->addBasePlaceTypes(); |
@@ -86,8 +88,9 @@ discard block |
||
86 | 88 | */ |
87 | 89 | public static function createFromTree($param) |
88 | 90 | { |
89 | - if( !is_array($param) ) |
|
90 | - throw new \Exception('Matrix should be initialized with an array'); |
|
91 | + if( !is_array($param) ) { |
|
92 | + throw new \Exception('Matrix should be initialized with an array'); |
|
93 | + } |
|
91 | 94 | |
92 | 95 | $placesCollector = new PlacesCollector(); |
93 | 96 | $placesCollector->addBasePlaceTypes(); |
@@ -127,8 +130,9 @@ discard block |
||
127 | 130 | array_push($frontier, $vicino); |
128 | 131 | } |
129 | 132 | |
130 | - if ($vicino->isVisited()) |
|
131 | - continue; |
|
133 | + if ($vicino->isVisited()) { |
|
134 | + continue; |
|
135 | + } |
|
132 | 136 | |
133 | 137 | $vicino->setVisited(true); |
134 | 138 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | /** @var Place[][] $resultMatrix */ |
190 | 194 | $resultMatrix = array(); |
191 | 195 | |
192 | - if ( empty($places) ) |
|
193 | - throw new \Exception('First add the places'); |
|
196 | + if ( empty($places) ) { |
|
197 | + throw new \Exception('First add the places'); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | /** @var Place $startingPlace */ |
196 | 201 | $startingPlace = reset($places); |
@@ -96,8 +96,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | }); |