Ejemplo n.º 1
0
 /**
  * @param int                       $position
  * @param string                    $type
  * @param string                    $subType
  * @param array<string,string>|null $parameters
  * @param float                     $quality
  * @param array<string,string>|null $extensions
  */
 public function __construct($position, $type, $subType, $parameters = null, $quality = 1.0, $extensions = null)
 {
     parent::__construct($type, $subType, $parameters);
     if (is_int($position) === false || $position < 0) {
         throw new InvalidArgumentException('position');
     }
     // rfc2616: 3 digits are meaningful (#3.9 Quality Values)
     $quality = floor((double) $quality * 1000) / 1000;
     if ($quality < 0 || $quality > 1) {
         throw new InvalidArgumentException('quality');
     }
     if ($extensions !== null && is_array($extensions) === false) {
         throw new InvalidArgumentException('extensions');
     }
     $this->position = $position;
     $this->quality = $quality;
     $this->extensions = $extensions;
 }
Ejemplo n.º 2
0
 /**
  * @param int    $position
  * @param string $mediaType
  *
  * @return MediaTypeInterface
  */
 protected static function parseMediaType($position, $mediaType)
 {
     return MediaType::parse($position, $mediaType);
 }