isNull = $isNull; $this->scheme = $scheme; $this->host = $host; $this->port = $port; } public function isNull(): bool { return $this->isNull; } public function isValid(): bool { return $this->isNull || ($this->scheme !== '' && $this->host !== ''); } public function getScheme(): string { return $this->scheme; } public function getHost(): string { return $this->host; } public function hasPort(): bool { return $this->port > 0; } public function getPort(): int { return $this->port; } public static function parse(HttpHeader $header): OriginHeader { $line = $header->getFirstLine(); if($line === 'null') return new OriginHeader(true, '', '', -1); return new OriginHeader( false, parse_url($line, PHP_URL_SCHEME) ?? '', parse_url($line, PHP_URL_HOST) ?? '', parse_url($line, PHP_URL_PORT) ?? -1 ); } }