protected function points() { $points = array(); foreach ($this->points as $i => $pos) { $points[$i] = array('x' => $pos[0], 'y' => $pos[1]); } if (count($points) < 3) { throw new \Exception('Polygon needs at least 3 points.'); } return $points; }