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

GitHubUsernamePassword   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 17
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAuthorizationHeader() 0 3 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