code: public function format(Polygon $polygon): string
      {
          if ($polygon->getNumberOfPoints() < 3) {
              throw new InvalidPolygonException('A polygon must consist of at least three points.');
          }
  
          $points = [];
  
          /** @var Coordinate $point */
          foreach ($polygon->getPoints() as $point) {
              $points[] = [$point->getLng(), $point->getLat()];
          }
  
          return json_encode(
              [
                  'type' => 'Polygon',
                  'coordinates' => [$points],
              ]
          );
      }
docs: @param Polygon $polygon
  
  @return string
  
  @throws InvalidPolygonException