Completed
Push — master ( eb09e4...f908c3 )
by Leo
01:56
created

Authorization   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 0
loc 33
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBasicAuth() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
namespace leocata\M1;
4
5
/**
6
 * Class Authorization.
7
 */
8
class Authorization
9
{
10
    /**
11
     * @var string
12
     */
13
    private $username;
14
15
    /**
16
     * @var string
17
     */
18
    private $password;
19
20
    /**
21
     * Authorization constructor.
22
     *
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
     *
35
     * @return array
36
     */
37
    public function getBasicAuth(): array
38
    {
39
        return [
40
            'Authorization' => 'Basic '.base64_encode($this->username.':'.$this->password),
41
        ];
42
    }
43
}
44