Auth::setToken()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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($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()
36
    {
37
        return [
38 9
            'Authorization' => 'Bearer '.$this->getToken(),
39 9
            'Accept'        => 'application/json',
40 9
            'Content-Type'  => 'application/json'
41
        ];
42
    }
43
44
    /**
45
     * @param $token
46
     */
47 10
    private function setToken($token)
48
    {
49 10
        $this->token = $token;
50 10
    }
51
52
53
    /**
54
     * @return string
55
     */
56 9
    private function getToken()
57
    {
58 9
        return $this->token;
59
    }
60
}
61