HeadersInterface.php
91 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Slim Framework (https://slimframework.com) |
| 5 | * |
| 6 | * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License) |
| 7 | */ |
| 8 | |
| 9 | declare(strict_types=1); |
| 10 | |
| 11 | namespace Slim\Psr7\Interfaces; |
| 12 | |
| 13 | use InvalidArgumentException; |
| 14 | |
| 15 | interface HeadersInterface |
| 16 | { |
| 17 | /** |
| 18 | * Add header value |
| 19 | * |
| 20 | * This method appends the value to the existing array of values |
| 21 | * |
| 22 | * @param string $name |
| 23 | * @param array|string $value |
| 24 | * |
| 25 | * @return HeadersInterface |
| 26 | * |
| 27 | * @throws InvalidArgumentException |
| 28 | */ |
| 29 | public function addHeader($name, $value): HeadersInterface; |
| 30 | |
| 31 | /** |
| 32 | * Remove header value |
| 33 | * |
| 34 | * @param string $name |
| 35 | * @return HeadersInterface |
| 36 | */ |
| 37 | public function removeHeader(string $name): HeadersInterface; |
| 38 | |
| 39 | /** |
| 40 | * Get header value or values. |
| 41 | * If the array has a single value it will return that single value. |
| 42 | * If the array has multiple values, it will return an array of values. |
| 43 | * |
| 44 | * @param string $name |
| 45 | * @param string[] $default |
| 46 | * |
| 47 | * @return array |
| 48 | */ |
| 49 | public function getHeader(string $name, $default = []): array; |
| 50 | |
| 51 | /** |
| 52 | * Replaces the existing header value with the new value. |
| 53 | * |
| 54 | * @param string $name |
| 55 | * @param array|string $value |
| 56 | * |
| 57 | * @return HeadersInterface |
| 58 | * |
| 59 | * @throws InvalidArgumentException |
| 60 | */ |
| 61 | public function setHeader($name, $value): HeadersInterface; |
| 62 | |
| 63 | /** |
| 64 | * Replaces all existing headers with the new values. |
| 65 | * |
| 66 | * @param array $headers |
| 67 | * |
| 68 | * @return HeadersInterface |
| 69 | * |
| 70 | * @throws InvalidArgumentException |
| 71 | */ |
| 72 | public function setHeaders(array $headers): HeadersInterface; |
| 73 | |
| 74 | /** |
| 75 | * Is the header present in the stack. |
| 76 | * |
| 77 | * @param string $name |
| 78 | * @return bool |
| 79 | */ |
| 80 | public function hasHeader(string $name): bool; |
| 81 | |
| 82 | /** |
| 83 | * Return all headers in the stack. |
| 84 | * |
| 85 | * @param bool $originalCase |
| 86 | * |
| 87 | * @return array |
| 88 | */ |
| 89 | public function getHeaders(bool $originalCase): array; |
| 90 | } |
| 91 |