Beispiel #1
0
 public function __construct(string $language, SetInterface $links, int $parsingTime)
 {
     if ((string) $links->type() !== UrlInterface::class) {
         throw new InvalidArgumentException();
     }
     $this->attribute = new Attribute($language, (new RemoveDuplicatedUrls())($links), $parsingTime);
 }
Beispiel #2
0
 public function __construct(SetInterface $mask)
 {
     if ((string) $mask->type() !== 'string') {
         throw new InvalidArgumentException();
     }
     $this->mask = $mask;
 }
Beispiel #3
0
 public function __construct(SetInterface $toRemove)
 {
     if ((string) $toRemove->type() !== 'string') {
         throw new InvalidArgumentException();
     }
     $this->toRemove = $toRemove;
 }
 public function __construct(SetInterface $extractors)
 {
     if ((string) $extractors->type() !== ExtractorInterface::class) {
         throw new InvalidArgumentException();
     }
     $this->extractors = $extractors;
 }
Beispiel #5
0
 public function __construct(string $name, SetInterface $values)
 {
     if ((string) $values->type() !== HeaderValueInterface::class) {
         throw new InvalidArgumentException();
     }
     $this->name = $name;
     $this->values = $values;
 }
Beispiel #6
0
 public function __construct(SetInterface $values)
 {
     $values->foreach(function (HeaderValueInterface $value) {
         if (!$value instanceof AcceptLanguageValue) {
             throw new InvalidArgumentException();
         }
     });
     parent::__construct('Accept-Language', $values);
 }
Beispiel #7
0
 public function __construct(string $name, TypeInterface $type, Access $access, SetInterface $variants, bool $optional)
 {
     if ((string) $variants->type() !== 'string') {
         throw new InvalidArgumentException();
     }
     $this->name = $name;
     $this->type = $type;
     $this->access = $access;
     $this->variants = $variants;
     $this->optional = $optional;
 }
Beispiel #8
0
 public function __construct(SetInterface $values)
 {
     if ($values->size() === 0) {
         throw new AcceptHeaderMustContainAtLeastOneValueException();
     }
     $values->foreach(function (HeaderValueInterface $value) {
         if (!$value instanceof AcceptValue) {
             throw new InvalidArgumentException();
         }
     });
     parent::__construct('Accept', $values);
 }
Beispiel #9
0
 public function __construct(string $name, SetInterface $types, int $priority)
 {
     if ((string) $types->type() !== MediaType::class || $types->size() === 0) {
         throw new InvalidArgumentException();
     }
     $this->name = $name;
     $this->types = $types;
     $this->priority = $priority;
     $this->preferredType = $types->sort(function (MediaType $a, MediaType $b) : bool {
         return $a->priority() < $b->priority();
     })->first();
 }
Beispiel #10
0
 public function __construct(SetInterface $values)
 {
     if ($values->size() === 0) {
         throw new CacheControlHeaderMustContainAtLeastOneValueException();
     }
     $values->foreach(function (HeaderValueInterface $header) {
         if (!$header instanceof CacheControlValueInterface) {
             throw new InvalidArgumentException();
         }
     });
     parent::__construct('Cache-Control', $values);
 }
Beispiel #11
0
 protected function parseValues(SetInterface $values)
 {
     return $values->current();
 }
Beispiel #12
0
 /**
  * Make sure the set is compatible with the current one
  *
  * @param SetInterface $set
  *
  * @throws InvalidArgumentException
  *
  * @return void
  */
 private function validate(SetInterface $set)
 {
     if (!$set->type()->equals($this->type)) {
         throw new InvalidArgumentException('The 2 sets does not reference the same type');
     }
 }
Beispiel #13
0
 protected function parseValues(SetInterface $values)
 {
     return Url::fromString($values->current());
 }