Skip to content

Commit 7f517fe

Browse files
committed
tests: fix in Map.php fromArray()
1 parent 2b04f24 commit 7f517fe

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/Map/src/Map.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,21 @@ public function addPolygon(Polygon $polygon): self
103103
public function addPolyline(Polyline $polyline): self
104104
{
105105
$this->polylines[] = $polyline;
106-
107106
return $this;
108107
}
109-
108+
110109
public function toArray(): array
111110
{
112111
if (!$this->fitBoundsToMarkers) {
113112
if (null === $this->center) {
114113
throw new InvalidArgumentException('The map "center" must be explicitly set when not enabling "fitBoundsToMarkers" feature.');
115114
}
116-
115+
117116
if (null === $this->zoom) {
118117
throw new InvalidArgumentException('The map "zoom" must be explicitly set when not enabling "fitBoundsToMarkers" feature.');
119118
}
120119
}
121-
120+
122121
return [
123122
'center' => $this->center?->toArray(),
124123
'zoom' => $this->zoom,
@@ -146,32 +145,31 @@ public function toArray(): array
146145
public static function fromArray(array $map): self
147146
{
148147
$map['fitBoundsToMarkers'] = true;
149-
150148
if (isset($map['center'])) {
151149
$map['center'] = Point::fromArray($map['center']);
152150
}
153-
151+
154152
if (isset($map['zoom']) || isset($map['center'])) {
155153
$map['fitBoundsToMarkers'] = false;
156154
}
157-
155+
158156
$map['markers'] ??= [];
159157
if (!\is_array($map['markers'])) {
160158
throw new InvalidArgumentException('The "markers" parameter must be an array.');
161159
}
162160
$map['markers'] = array_map(Marker::fromArray(...), $map['markers']);
163-
161+
164162
$map['polygons'] ??= [];
165163
if (!\is_array($map['polygons'])) {
166164
throw new InvalidArgumentException('The "polygons" parameter must be an array.');
167165
}
168166
$map['polygons'] = array_map(Polygon::fromArray(...), $map['polygons']);
169-
167+
170168
$map['polylines'] ??= [];
171169
if (!\is_array($map['polylines'])) {
172170
throw new InvalidArgumentException('The "polylines" parameter must be an array.');
173171
}
174-
$map['polylines'] = array_map(Polygon::fromArray(...), $map['polylines']);
172+
$map['polylines'] = array_map(Polyline::fromArray(...), $map['polylines']);
175173

176174
return new self(...$map);
177175
}

0 commit comments

Comments
 (0)