Passed
Push — feature/api-versions ( 00c9fc...d9c41a )
by Robin
25:41 queued 16:25
created

BearerAuth::getHeaders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Konsulting\JustGivingApiSdk\Support\Auth;
4
5
class BearerAuth 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 bearer token obtained via oAuth.
17
     *
18
     * @see https://justgivingdeveloper.zendesk.com/hc/en-us/articles/207071499-Getting-a-bearer-token
19
     * @var string
20
     */
21
    protected $token;
22
23
    /**
24
     * The secret key provided by JustGiving (this currently has to be requested manually).
25
     *
26
     * @see https://justgivingdeveloper.zendesk.com/hc/en-us/articles/115002238925-How-do-I-get-a-secret-key-
27
     * @var string
28
     */
29
    protected $secretKey;
30
31
    public function __construct($appId, $secretKey, $token)
32
    {
33
        $this->appId = $appId;
34
        $this->token = $token;
35
        $this->secretKey = $secretKey;
36
    }
37
38
    /**
39
     * Get the authentication headers.
40
     *
41
     * @return array
42
     */
43 1
    public function getHeaders()
44
    {
45
        return [
46 1
            'Authorization'     => 'Bearer ' . $this->token,
47 1
            'x-api-key'         => $this->appId,
48 1
            'x-application-key' => $this->secretKey,
49
        ];
50
    }
51
}
52