Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/Headers/HttpAuthorizationHeader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace WrkFlow\ApiSdkBuilder\Headers;

use WrkFlow\ApiSdkBuilder\Interfaces\HeadersInterface;

class HttpAuthorizationHeader implements HeadersInterface
{
public function __construct(
#[\SensitiveParameter] public readonly string $username,
#[\SensitiveParameter] public readonly string $password,
) {
}

public function headers(): array
{
$key = base64_encode(
sprintf(
'%s:%s',
$this->username,
$this->password,
),
);

return [
'Authorization' => sprintf('Basic %s', $key),
];
}
}