34 lines
779 B
PHP
34 lines
779 B
PHP
<?php
|
|
// TrailerHeader.php
|
|
// Created: 2022-02-14
|
|
// Updated: 2022-02-27
|
|
|
|
namespace Index\Http\Headers;
|
|
|
|
use Index\Http\HttpHeader;
|
|
|
|
class TrailerHeader {
|
|
private array $headers;
|
|
|
|
public function __construct(array $headers) {
|
|
$this->headers = $headers;
|
|
}
|
|
|
|
public function getHeaders(): array {
|
|
return $this->headers;
|
|
}
|
|
|
|
public function isTrailer(string $header): bool {
|
|
return in_array(strtolower($header), $this->headers);
|
|
}
|
|
|
|
public static function parse(HttpHeader $header): TrailerHeader {
|
|
$raw = explode(',', $header->getFirstLine());
|
|
$headers = [];
|
|
|
|
foreach($raw as $header)
|
|
$headers[] = strtolower(trim($header));
|
|
|
|
return new TrailerHeader(array_unique($headers));
|
|
}
|
|
}
|