Client::getUsername()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pixela;
4
5
use ReflectionClass;
6
7
class Client implements ClientInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $username;
13
14
    /**
15
     * @var string
16
     */
17
    private $token;
18
19
    /**
20
     * @var \GuzzleHttp\ClientInterface
21
     */
22
    private $httpClient;
23
24
    /**
25
     * Client constructor.
26
     * @param $username
27
     * @param $token
28
     * @param \GuzzleHttp\ClientInterface|null $httpClient
29
     */
30
    public function __construct($username = null, $token = null, \GuzzleHttp\ClientInterface $httpClient = null)
31
    {
32
        $this->username = $username;
33
        $this->token = $token;
34
        $this->httpClient = ($httpClient !== null) ? $httpClient : new \GuzzleHttp\Client();
35
    }
36
37
    /**
38
     * @param $name
39
     * @return object
40
     * @throws \ReflectionException
41
     */
42
    public function api($name)
43
    {
44
        $class = new ReflectionClass('Pixela\Api\\' . $name);
45
        return $class->newInstanceArgs(array($this));
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getUsername()
52
    {
53
        return $this->username;
54
    }
55
56
    /**
57
     * @param string $username
58
     */
59
    public function setUsername($username)
60
    {
61
        $this->username = $username;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getToken()
68
    {
69
        return $this->token;
70
    }
71
72
    /**
73
     * @param string $token
74
     */
75
    public function setToken($token)
76
    {
77
        $this->token = $token;
78
    }
79
80
    /**
81
     * @return \GuzzleHttp\ClientInterface
82
     */
83
    public function getHttpClient()
84
    {
85
        return $this->httpClient;
86
    }
87
88
    /**
89
     * @param \GuzzleHttp\ClientInterface $httpClient
90
     */
91
    public function setHttpClient(\GuzzleHttp\ClientInterface $httpClient)
92
    {
93
        $this->httpClient = $httpClient;
94
    }
95
}
96