for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace InShore\Bookwhen\ValueObjects\Transporter;
use InShore\Bookwhen\ValueObjects\ApiKey;
/**
* @internal
*/
final class Headers
{
* Creates a new Headers value object.
*
* @param array<string, string> $headers
private function __construct(private readonly array $headers)
// ..
}
* Creates a new Headers value object
public static function create(): self
return new self([]);
* Creates a new Headers value object with the given API token.
public static function withAuthorization(ApiKey $apiKey): self
return new self([
'Authorization' => 'Basic ' . base64_encode($apiKey->toString() . ':')
]);
* Creates a new Headers value object, with the given content type, and the existing headers.
public function withContentType(): self
...$this->headers,
'Content-Type' => 'application/json',
* @return array<string, string> $headers
public function toArray(): array
return $this->headers;