0 follower

Final Class Yiisoft\ErrorHandler\HeadersProvider

InheritanceYiisoft\ErrorHandler\HeadersProvider

HeadersProvider provides headers for error response.

It is used by {@see \Yiisoft\ErrorHandler\Middleware\ErrorCatcher} to add headers to response in case of error.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\ErrorHandler\HeadersProvider
add() Adds a header to the list of headers. Yiisoft\ErrorHandler\HeadersProvider
getAll() Returns all headers. Yiisoft\ErrorHandler\HeadersProvider

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( array<string, string[]> $headers = [] )
$headers array<string, string[]>

Default headers list.

                public function __construct(
    private array $headers = [],
) {
}

            
add() public method

Adds a header to the list of headers.

public void add ( string $name, string|string[] $values )
$name string

The header name.

$values string|string[]

The header value.

                public function add(string $name, string|array $values): void
{
    $this->headers[$name] = (array)$values;
}

            
getAll() public method

Returns all headers.

public array<string, string[]> getAll ( )
return array<string, string[]>

The headers list.

                public function getAll(): array
{
    return $this->headers;
}