Passed
Push — master ( 053cae...6a3053 )
by Alessandro
42s
created

Auth   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 47
c 0
b 0
f 0
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getToken() 0 3 1
A setToken() 0 3 1
A getHeaders() 0 8 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: aless
5
 * Date: 13/03/2019
6
 * Time: 14:13
7
 */
8
9
namespace Bitlywrap\Auth;
10
11
use Bitlywrap\Interfaces\AuthInterface;
12
13
class Auth implements AuthInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    private $token;
19
20
    /**
21
     * AuthInterface constructor.
22
     *
23
     * @param string $token
24
     */
25 10
    public function __construct(string $token)
26
    {
27 10
        $this->setToken($token);
28 10
    }
29
30
    /**
31
     * Prepare the headers for successive implementations
32
     *
33
     * @return array
34
     */
35 9
    public function getHeaders(): array
36
    {
37
        $headers = [
38 9
            'Authorization' => 'Bearer '.$this->getToken(),
39 9
            'Accept'        => 'application/json',
40 9
            'Content-Type'  => 'application/json'
41
        ];
42 9
        return $headers;
43
    }
44
45
    /**
46
     * @param $token
47
     */
48 10
    private function setToken($token)
49
    {
50 10
        $this->token = $token;
51 10
    }
52
53
54
    /**
55
     * @return string
56
     */
57 9
    private function getToken()
58
    {
59 9
        return $this->token;
60
    }
61
}
62