public function getPerimeter(DistanceInterface $calculator): float
    {
        $perimeter = 0.0;

        if (count($this->points) < 2) {
            return $perimeter;
        }

        foreach ($this->getSegments() as $segment) {
            $perimeter += $segment->getLength($calculator);
        }

        return $perimeter;
    }
public function getPerimeter(DistanceInterface $calculator): float
    {
        $perimeter = 0.0;

        if (count($this->points) < 2) {
            return $perimeter;
        }

        foreach ($this->getSegments() as $segment) {
            $perimeter += $segment->getLength($calculator);
        }

        return $perimeter;
    }
public function getPerimeter ( DistanceInterface $ calculator ) : float { $ perimeter = 0.0 ; if ( count ( $ this -> points ) < 2 ) { return $ perimeter ; } foreach ( $ this -> getSegments ( ) as $ segment ) { $ perimeter += $ segment -> getLength ( $ calculator ) ; } return $ perimeter ; }
Calculates the polygon perimeter.

@param DistanceInterface $calculator instance of distance calculation class

@return float
Calculates the polygon perimeter .