code: private function getLegendProperty(LegendInterface $legend, $propertyName)
      {
          if ($legend->hasProperty($propertyName)) {
              $property = $legend->getProperty($propertyName);
          } else {
              $property = new Property($propertyName);
              $legend->addProperty($property);
          }
  
          return $property;
      }
docs: Get a property from a legend. Create if not exists.
  
  @param LegendInterface $legend       The legend.
  @param string          $propertyName The property name.
  
  @return PropertyInterface