| Conditions | 5 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 11 |
| Ratio | 57.89 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public static function fromPoints($points): Polygon |
||
| 22 | { |
||
| 23 | if (count($points) == 0) { |
||
| 24 | throw new \InvalidArgumentException('points'); |
||
| 25 | } |
||
| 26 | |||
| 27 | $normalized = []; |
||
| 28 | View Code Duplication | foreach ($points as $i => $point) { |
|
| 29 | if ($point instanceof Point) { |
||
| 30 | $normalized[] = $point; |
||
| 31 | } elseif (is_array($point)) { |
||
| 32 | $normalized[] = Point::fromCoords($point[0], $point[1]); |
||
| 33 | } else { |
||
| 34 | throw new \InvalidArgumentException("points[$i]"); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return new Polygon($normalized); |
||
| 39 | } |
||
| 40 | |||
| 79 |