Total Complexity | 9 |
Total Lines | 87 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
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() |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param \GuzzleHttp\ClientInterface $httpClient |
||
90 | */ |
||
91 | public function setHttpClient(\GuzzleHttp\ClientInterface $httpClient) |
||
94 | } |
||
95 | } |
||
96 |