Files
kiri-core/http-server/Message/Headers.php
T
2021-08-27 17:46:40 +08:00

45 lines
584 B
PHP

<?php
namespace Server\Message;
class Headers
{
private array $headers = [];
/**
* @param array $headers
* @return $this
*/
public function withHeader(array $headers): static
{
$class = clone $this;
$class->headers = $headers;
return $class;
}
/**
* @param $name
* @param null $default
* @return string|array|float|int|null
*/
public function get($name, $default = null): string|array|float|int|null
{
return $this->headers[$name] ?? $default;
}
/**
* @return array
*/
public function toArray(): array
{
return $this->headers;
}
}