Completed
Push — master ( 048bf8...346c21 )
by Leo
03:28
created

HttpClientAuthorization::getBasicAuth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace leocata\M1;
4
5
/**
6
 * Class HttpClientAuthorization
7
 * @package leocata\M1
8
 */
9
class HttpClientAuthorization
10
{
11
    /**
12
     * @var string
13
     */
14
    private $username;
15
16
    /**
17
     * @var string
18
     */
19
    private $password;
20
21
    /**
22
     * HttpClientAuthorization constructor.
23
     * @param string $username
24
     * @param string $password
25
     */
26 2
    public function __construct(string $username, string $password)
27
    {
28 2
        $this->username = $username;
29 2
        $this->password = $password;
30 2
    }
31
32
    /**
33
     * The authorization header will be generated and added as a custom header
34
     * @return array
35
     */
36
    public function getBasicAuth(): array
37
    {
38
        return [
39
            'Authorization' => 'Basic ' . base64_encode($this->username . ':' . $this->password),
40
        ];
41
    }
42
}
43