Completed
Push — v3 ( d12fea )
by Beñat
05:39
created

Authentication   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

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
 * Copyright (c) 2014-2016 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
namespace BenatEspina\StackExchangeApiClient\Domain\Model;
13
14
/**
15
 * Authentication domain class.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
final class Authentication
20
{
21
    /**
22
     * The key that makes requests against the
23
     * API to receive a higher request quota.
24
     *
25
     * @var string
26
     */
27
    private $key;
28
29
    /**
30
     * The access token.
31
     *
32
     * @var string
33
     */
34
    private $accessToken;
35
36
    /**
37
     * Constructor.
38
     *
39
     * @param string $aKey          The key
40
     * @param string $anAccessToken The access token
41
     */
42
    public function __construct($aKey, $anAccessToken)
43
    {
44
        $this->key = $aKey;
45
        $this->accessToken = $anAccessToken;
46
    }
47
48
    /**
49
     * Gets the key.
50
     *
51
     * @return string
52
     */
53
    public function key()
54
    {
55
        return $this->key;
56
    }
57
58
    /**
59
     * Gets the access token.
60
     *
61
     * @return string
62
     */
63
    public function accessToken()
64
    {
65
        return $this->accessToken;
66
    }
67
68
    /**
69
     * Gets the key and access token in array format.
70
     *
71
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,string>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
72
     */
73
    public function toArray()
74
    {
75
        return ['key' => $this->key, 'access_token' => $this->accessToken];
76
    }
77
78
    /**
79
     * Gets the key and access token in url format.
80
     *
81
     * @return string
82
     */
83
    public function toUrl()
84
    {
85
        return '&access_token=' . $this->accessToken . '&key=' . $this->key;
86
    }
87
}
88