index/src/Http/Headers/TrailerHeader.php

35 lines
779 B
PHP
Raw Normal View History

2022-09-13 13:13:11 +00:00
<?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));
}
}