Completed
Push — master ( f5580e...4e6c29 )
by Beñat
01:39
created

Authentication   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A key() 0 4 1
A accessToken() 0 4 1
A toArray() 0 4 1
A toUrl() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace BenatEspina\StackExchangeApiClient\Authentication;
15
16
/**
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
final class Authentication
20
{
21
    private $key;
22
    private $accessToken;
23
24
    public function __construct(string $key, string $accessToken)
25
    {
26
        $this->key = $key;
27
        $this->accessToken = $accessToken;
28
    }
29
30
    public function key() : string
31
    {
32
        return $this->key;
33
    }
34
35
    public function accessToken() : string
36
    {
37
        return $this->accessToken;
38
    }
39
40
    public function toArray() : array
41
    {
42
        return ['key' => $this->key, 'access_token' => $this->accessToken];
43
    }
44
45
    public function toUrl() : string
46
    {
47
        return '&access_token=' . $this->accessToken . '&key=' . $this->key;
48
    }
49
}
50