Test Failed
Push — feature/api-versions ( a57f4c...a08e88 )
by Robin
02:32
created

BasicAuth   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 44
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeaders() 0 7 1
A __construct() 0 6 1
1
<?php
2
3
namespace Konsulting\JustGivingApiSdk\Support\Auth;
4
5
class BasicAuth implements AuthValue
6
{
7
    /**
8
     * The application ID (also known as API key).
9
     *
10
     * @see https://developer.justgiving.com/apidocs/documentation#AppId
11
     * @var string
12
     */
13
    protected $appId;
14
15
    /**
16
     * The username of the JustGiving user being authenticated.
17
     *
18
     * @var string
19
     */
20
    protected $username;
21
22
    /**
23
     * The password of the JustGiving user being authenticated.
24
     *
25
     * @var string
26
     */
27
    protected $password;
28
29 9
    public function __construct($appId, $username, $password)
30
    {
31 9
        $this->username = $username;
32 9
        $this->password = $password;
33 9
        $this->appId = $appId;
34 9
    }
35
36
    /**
37
     * Get the authentication headers.
38
     *
39
     * @return array
40
     */
41 9
    public function getHeaders()
42
    {
43
        return [
44 9
            'Authorization' => 'Basic ' . base64_encode($this->username . ":" . $this->password),
45 9
            'x-api-key'     => $this->appId,
46
        ];
47
    }
48
}
49