Passed
Pull Request — master (#7)
by Laurens
05:33
created

HttpBasic::getHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Werkspot\KvkApi\Client\Authentication;
6
7
final class HttpBasic implements AuthenticationInterface
8
{
9
    private $username;
10
11
    private $password;
12
13 19
    public function __construct(string $username, string $password)
14
    {
15 19
        $this->username = $username;
16 19
        $this->password = $password;
17 19
    }
18
19 19
    public function getHeader(): string
20
    {
21 19
        $hash = base64_encode(sprintf('%s:%s', $this->username, $this->password));
22
23 19
        return sprintf('Authorization:Basic %s', $hash);
24
    }
25
}
26