![]() Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : fdshops ( 1003) PHP Version : 8.2.21 Disable Function : NONE Directory : /home/fdshops/public_html/vendor/openai-php/client/src/ValueObjects/Transporter/ |
<?php declare(strict_types=1); namespace OpenAI\ValueObjects\Transporter; use OpenAI\Enums\Transporter\ContentType; use OpenAI\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' => "Bearer {$apiKey->toString()}", ]); } /** * Creates a new Headers value object, with the given content type, and the existing headers. */ public function withContentType(ContentType $contentType, string $suffix = ''): self { return new self([ ...$this->headers, 'Content-Type' => $contentType->value.$suffix, ]); } /** * Creates a new Headers value object, with the given organization, and the existing headers. */ public function withOrganization(string $organization): self { return new self([ ...$this->headers, 'OpenAI-Organization' => $organization, ]); } /** * Creates a new Headers value object, with the newly added header, and the existing headers. */ public function withCustomHeader(string $name, string $value): self { return new self([ ...$this->headers, $name => $value, ]); } /** * @return array<string, string> $headers */ public function toArray(): array { return $this->headers; } }