Exemplo n.º 1
0
 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'range') {
         throw new InvalidArgumentException();
     }
     $matches = $value->getMatches('~^(?<unit>\\w+)=(?<first>\\d+)-(?<last>\\d+)$~');
     return new Range(new RangeValue((string) $matches->get('unit'), (int) (string) $matches->get('first'), (int) (string) $matches->get('last')));
 }
Exemplo n.º 2
0
 public static function fromString(string $type, Types $types) : TypeInterface
 {
     $type = new Str($type);
     if (!$type->match(self::PATTERN)) {
         throw new InvalidArgumentException();
     }
     return new self((string) $type->getMatches(self::PATTERN)->get('format'));
 }
Exemplo n.º 3
0
 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'authorization') {
         throw new InvalidArgumentException();
     }
     $matches = $value->getMatches('~^"?(?<scheme>\\w+)"? ?(?<param>.+)?$~');
     return new Authorization(new AuthorizationValue((string) $matches->get('scheme'), $matches->hasKey('param') ? (string) $matches->get('param') : ''));
 }