コード例 #1
0
ファイル: Format.php プロジェクト: innmind/rest-client
 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();
 }
コード例 #2
0
ファイル: Accept.php プロジェクト: innmind/http
 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);
 }
コード例 #3
0
ファイル: CacheControl.php プロジェクト: innmind/http
 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);
 }