tag = $tag; $this->dateTime = $dateTime; } public function hasTag(): bool { return $this->tag !== null; } public function getTag(): string { return $this->tag; } public function hasDateTime(): bool { return $this->dateTime !== null; } public function getDateTime(): DateTime { return $this->dateTime; } public function matches(string|DateTimeInterface $other): bool { if($this->hasTag() && is_string($other)) { if(str_starts_with($other, 'W/"')) return false; return $this->tag === $other; } if($this->hasDateTime() && $other instanceof DateTimeInterface) return $this->dateTime->isLessThanOrEqual($other); return false; } public static function parse(HttpHeader $header): IfRangeHeader { $line = $header->getFirstLine(); if($line[0] !== '"' && !str_starts_with($line, 'W/"')) return new IfRangeHeader(null, DateTime::createFromFormat(\DateTimeInterface::RFC7231, $line)); return new IfRangeHeader($line, null); } }