@@ -103,21 +103,22 @@ public function addPolygon(Polygon $polygon): self
103103 public function addPolyline (Polyline $ polyline ): self
104104 {
105105 $ this ->polylines [] = $ polyline ;
106+
106107 return $ this ;
107108 }
108-
109+
109110 public function toArray (): array
110111 {
111112 if (!$ this ->fitBoundsToMarkers ) {
112113 if (null === $ this ->center ) {
113114 throw new InvalidArgumentException ('The map "center" must be explicitly set when not enabling "fitBoundsToMarkers" feature. ' );
114115 }
115-
116+
116117 if (null === $ this ->zoom ) {
117118 throw new InvalidArgumentException ('The map "zoom" must be explicitly set when not enabling "fitBoundsToMarkers" feature. ' );
118119 }
119120 }
120-
121+
121122 return [
122123 'center ' => $ this ->center ?->toArray(),
123124 'zoom ' => $ this ->zoom ,
@@ -148,23 +149,23 @@ public static function fromArray(array $map): self
148149 if (isset ($ map ['center ' ])) {
149150 $ map ['center ' ] = Point::fromArray ($ map ['center ' ]);
150151 }
151-
152+
152153 if (isset ($ map ['zoom ' ]) || isset ($ map ['center ' ])) {
153154 $ map ['fitBoundsToMarkers ' ] = false ;
154155 }
155-
156+
156157 $ map ['markers ' ] ??= [];
157158 if (!\is_array ($ map ['markers ' ])) {
158159 throw new InvalidArgumentException ('The "markers" parameter must be an array. ' );
159160 }
160161 $ map ['markers ' ] = array_map (Marker::fromArray (...), $ map ['markers ' ]);
161-
162+
162163 $ map ['polygons ' ] ??= [];
163164 if (!\is_array ($ map ['polygons ' ])) {
164165 throw new InvalidArgumentException ('The "polygons" parameter must be an array. ' );
165166 }
166167 $ map ['polygons ' ] = array_map (Polygon::fromArray (...), $ map ['polygons ' ]);
167-
168+
168169 $ map ['polylines ' ] ??= [];
169170 if (!\is_array ($ map ['polylines ' ])) {
170171 throw new InvalidArgumentException ('The "polylines" parameter must be an array. ' );
0 commit comments