@@ -45,17 +45,17 @@ |
||
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 |
@@ -51,7 +51,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -51,8 +51,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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); |