30 lines
678 B
PHP
30 lines
678 B
PHP
<?php
|
|
// ContentEncodingHeader.php
|
|
// Created: 2022-02-14
|
|
// Updated: 2022-02-27
|
|
|
|
namespace Index\Http\Headers;
|
|
|
|
use Index\Http\HttpHeader;
|
|
|
|
class ContentEncodingHeader {
|
|
private array $encodings;
|
|
|
|
public function __construct(array $encodings) {
|
|
$this->encodings = $encodings;
|
|
}
|
|
|
|
public function getEncodings(): array {
|
|
return $this->encodings;
|
|
}
|
|
|
|
public static function parse(HttpHeader $header): ContentEncodingHeader {
|
|
return new ContentEncodingHeader(
|
|
array_map(
|
|
fn($directive) => trim($directive),
|
|
explode(',', strtolower($header->getFirstLine()))
|
|
)
|
|
);
|
|
}
|
|
}
|