@@ -8,75 +8,75 @@ |
||
8 | 8 | |
9 | 9 | class EndpointsContainer |
10 | 10 | { |
11 | - /* |
|
11 | + /* |
|
12 | 12 | * @var HttpInterface |
13 | 13 | */ |
14 | - protected $httpClient; |
|
14 | + protected $httpClient; |
|
15 | 15 | |
16 | - /* |
|
16 | + /* |
|
17 | 17 | * @var array |
18 | 18 | */ |
19 | - protected $endpoints = []; |
|
19 | + protected $endpoints = []; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param HttpClient $httpClient |
|
23 | - */ |
|
24 | - public function __construct(HttpClient $httpClient) |
|
25 | - { |
|
26 | - $this->httpClient = $httpClient; |
|
27 | - } |
|
21 | + /** |
|
22 | + * @param HttpClient $httpClient |
|
23 | + */ |
|
24 | + public function __construct(HttpClient $httpClient) |
|
25 | + { |
|
26 | + $this->httpClient = $httpClient; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param string $endpoint |
|
31 | - * @return Endpoint |
|
32 | - */ |
|
33 | - public function resolve($endpoint) |
|
34 | - { |
|
35 | - $endpoint = strtolower($endpoint); |
|
29 | + /** |
|
30 | + * @param string $endpoint |
|
31 | + * @return Endpoint |
|
32 | + */ |
|
33 | + public function resolve($endpoint) |
|
34 | + { |
|
35 | + $endpoint = strtolower($endpoint); |
|
36 | 36 | |
37 | - // Check if an instance has already been initiated |
|
38 | - if (!isset($this->endpoints[$endpoint])) { |
|
39 | - $this->addProvider($endpoint); |
|
40 | - } |
|
37 | + // Check if an instance has already been initiated |
|
38 | + if (!isset($this->endpoints[$endpoint])) { |
|
39 | + $this->addProvider($endpoint); |
|
40 | + } |
|
41 | 41 | |
42 | - return $this->endpoints[$endpoint]; |
|
43 | - } |
|
42 | + return $this->endpoints[$endpoint]; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param $endpoint |
|
47 | - * @throws WrongEndpoint |
|
48 | - */ |
|
49 | - protected function addProvider($endpoint) |
|
50 | - { |
|
51 | - $className = __NAMESPACE__ . '\\' . ucfirst($endpoint); |
|
45 | + /** |
|
46 | + * @param $endpoint |
|
47 | + * @throws WrongEndpoint |
|
48 | + */ |
|
49 | + protected function addProvider($endpoint) |
|
50 | + { |
|
51 | + $className = __NAMESPACE__ . '\\' . ucfirst($endpoint); |
|
52 | 52 | |
53 | - if (!class_exists($className)) { |
|
54 | - throw new WrongEndpoint("Endpoint $className not found."); |
|
55 | - } |
|
53 | + if (!class_exists($className)) { |
|
54 | + throw new WrongEndpoint("Endpoint $className not found."); |
|
55 | + } |
|
56 | 56 | |
57 | - $this->endpoints[$endpoint] = $this->buildEndpoint($className); |
|
58 | - } |
|
57 | + $this->endpoints[$endpoint] = $this->buildEndpoint($className); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $className |
|
62 | - * @return Endpoint|object |
|
63 | - */ |
|
64 | - protected function buildEndpoint($className) |
|
65 | - { |
|
66 | - return (new ReflectionClass($className))->newInstanceArgs([$this->httpClient]); |
|
67 | - } |
|
60 | + /** |
|
61 | + * @param string $className |
|
62 | + * @return Endpoint|object |
|
63 | + */ |
|
64 | + protected function buildEndpoint($className) |
|
65 | + { |
|
66 | + return (new ReflectionClass($className))->newInstanceArgs([$this->httpClient]); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - public function getRateInfo() |
|
73 | - { |
|
74 | - $responseHeaders = $this->httpClient->getResponseHeaders(); |
|
69 | + /** |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + public function getRateInfo() |
|
73 | + { |
|
74 | + $responseHeaders = $this->httpClient->getResponseHeaders(); |
|
75 | 75 | |
76 | - return [ |
|
77 | - 'reset' => $responseHeaders['X-RateLimit-Reset'][0], |
|
78 | - 'limit' => $responseHeaders['X-RateLimit-Limit'][0], |
|
79 | - 'remaining' => $responseHeaders['X-RateLimit-Remaining'][0], |
|
80 | - ]; |
|
81 | - } |
|
76 | + return [ |
|
77 | + 'reset' => $responseHeaders['X-RateLimit-Reset'][0], |
|
78 | + 'limit' => $responseHeaders['X-RateLimit-Limit'][0], |
|
79 | + 'remaining' => $responseHeaders['X-RateLimit-Remaining'][0], |
|
80 | + ]; |
|
81 | + } |
|
82 | 82 | } |