0 follower

Final Class Yiisoft\ErrorHandler\HeadersProvider

InheritanceYiisoft\ErrorHandler\HeadersProvider

HeadersProvider provides headers for error response.

It is used by 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 __construct( array<string, string[]> $headers = [] ): mixed
$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 add( string $name, string|string[] $values ): void
$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 getAll( ): array<string, string[]>
return array<string, string[]>

The headers list.

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