code: 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;
      }
docs: Calculates the polygon perimeter.
  
  @param DistanceInterface $calculator instance of distance calculation class
  
  @return float