| Total Complexity | 5 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 66.67% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class Headers |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Creates a new Headers value object. |
||
| 16 | * |
||
| 17 | * @param array<string, string> $headers |
||
| 18 | */ |
||
| 19 | 20 | private function __construct(private readonly array $headers) |
|
| 20 | { |
||
| 21 | // .. |
||
| 22 | 20 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * Creates a new Headers value object |
||
| 26 | */ |
||
| 27 | 20 | public static function create(): self |
|
| 28 | { |
||
| 29 | 20 | return new self([]); |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Creates a new Headers value object with the given API token. |
||
| 34 | */ |
||
| 35 | 20 | public static function withAuthorization(ApiKey $apiKey): self |
|
| 36 | { |
||
| 37 | 20 | return new self([ |
|
| 38 | 20 | 'Authorization' => 'Basic ' . base64_encode($apiKey->toString() . ':') |
|
| 39 | 20 | ]); |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Creates a new Headers value object, with the given content type, and the existing headers. |
||
| 44 | */ |
||
| 45 | public function withContentType(): self |
||
| 50 | ]); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return array<string, string> $headers |
||
| 55 | */ |
||
| 56 | 11 | public function toArray(): array |
|
| 61 |