1 | <?php |
||
24 | class Client |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $sApiUrl; |
||
30 | /** |
||
31 | * Cache handler |
||
32 | * |
||
33 | * @var CacheInterface |
||
34 | */ |
||
35 | private $oCache; |
||
36 | /** |
||
37 | * @var Adapter |
||
38 | */ |
||
39 | private $oCacheAdapter; |
||
40 | /** |
||
41 | * Logger handler |
||
42 | * |
||
43 | * @var \Psr\Log\LoggerInterface |
||
44 | */ |
||
45 | private $oLogger; |
||
46 | |||
47 | /** |
||
48 | * Client constructor. |
||
49 | * |
||
50 | * @param string $apiUrl |
||
51 | */ |
||
52 | 14 | public function __construct(string $apiUrl = 'https://api-v3.mojepanstwo.pl/') |
|
58 | |||
59 | /** |
||
60 | * @param string $url |
||
61 | * |
||
62 | * @return mixed |
||
63 | * @throws \mrcnpdlk\MojePanstwo\Exception |
||
64 | */ |
||
65 | 9 | private function curlRequest(string $url) |
|
92 | |||
93 | /** |
||
94 | * Get logger instance |
||
95 | * |
||
96 | * @return \Psr\Log\LoggerInterface |
||
97 | */ |
||
98 | 11 | public function getLogger(): LoggerInterface |
|
102 | |||
103 | /** |
||
104 | * @param string $sPrefixedContext |
||
105 | * @param string|null $id |
||
106 | * @param \mrcnpdlk\MojePanstwo\QueryBuilder|null $oParams |
||
107 | * |
||
108 | * @return \stdClass |
||
109 | * @throws \mrcnpdlk\MojePanstwo\Exception |
||
110 | */ |
||
111 | 9 | public function request(string $sPrefixedContext, string $id = null, QueryBuilder $oParams = null): \stdClass |
|
139 | |||
140 | /** |
||
141 | * Setting Cache Adapter |
||
142 | * |
||
143 | * @return $this |
||
144 | */ |
||
145 | 14 | private function setCacheAdapter() |
|
151 | |||
152 | /** |
||
153 | * Set Cache handler (PSR-16) |
||
154 | * |
||
155 | * @param \Psr\SimpleCache\CacheInterface|null $oCache |
||
156 | * |
||
157 | * @return \mrcnpdlk\MojePanstwo\Client |
||
158 | * @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md PSR-16 |
||
159 | */ |
||
160 | 14 | public function setCacheInstance(CacheInterface $oCache = null): Client |
|
167 | |||
168 | /** |
||
169 | * Set Logger handler (PSR-3) |
||
170 | * |
||
171 | * @param \Psr\Log\LoggerInterface|null $oLogger |
||
172 | * |
||
173 | * @return $this |
||
174 | */ |
||
175 | 14 | public function setLoggerInstance(LoggerInterface $oLogger = null) |
|
182 | |||
183 | } |
||
184 |