Completed
Push — master ( d4f713...589745 )
by Jonathan
12s queued 11s
created

GitHubUsernamePassword::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ChangelogGenerator;
6
7
use function base64_encode;
8
use function sprintf;
9
10
final class GitHubUsernamePassword implements GitHubCredentials
11
{
12
    /** @var string */
13
    private $username;
14
15
    /** @var string */
16
    private $passwordOrToken;
17
18 3
    public function __construct(string $username, string $passwordOrToken)
19
    {
20 3
        $this->username        = $username;
21 3
        $this->passwordOrToken = $passwordOrToken;
22 3
    }
23
24 2
    public function getAuthorizationHeader() : string
25
    {
26 2
        return sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->username, $this->passwordOrToken)));
27
    }
28
}
29