1 | <?php |
||
19 | class Client |
||
20 | { |
||
21 | use HttpTrait; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $namespace = __NAMESPACE__ . '\\Endpoints'; |
||
27 | |||
28 | /** |
||
29 | * Type of query |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $type; |
||
34 | |||
35 | /** |
||
36 | * Endpoint of query |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $endpoint; |
||
41 | |||
42 | /** |
||
43 | * Parameters of query |
||
44 | * |
||
45 | * @var mixed |
||
46 | */ |
||
47 | protected $params; |
||
48 | |||
49 | /** |
||
50 | * @var array |
||
51 | */ |
||
52 | protected static $variables = []; |
||
53 | |||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $query = []; |
||
59 | |||
60 | /** |
||
61 | * API constructor. |
||
62 | * |
||
63 | * @param array|Config $config |
||
64 | * @throws ErrorException |
||
65 | */ |
||
66 | public function __construct($config) |
||
89 | |||
90 | /** |
||
91 | * Append some value to query |
||
92 | * |
||
93 | * @param string $name |
||
94 | * @param string|int $value |
||
95 | * |
||
96 | * @return $this |
||
97 | */ |
||
98 | protected function appendToQuery(string $name, $value): self |
||
103 | |||
104 | /** |
||
105 | * Generate ready to use query from array of parameters |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | protected function getQuery(): string |
||
113 | |||
114 | /** |
||
115 | * Convert underscore_strings to camelCase (medial capitals). |
||
116 | * |
||
117 | * @param string $str |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | private function snakeToPascal(string $str): string |
||
126 | |||
127 | /** |
||
128 | * Magic method required for call of another classes |
||
129 | * |
||
130 | * @param string $name |
||
131 | * |
||
132 | * @return bool|object |
||
133 | * @throws BadMethodCallException |
||
134 | */ |
||
135 | public function __get(string $name) |
||
164 | |||
165 | /** |
||
166 | * Magic method required for call of another classes |
||
167 | * |
||
168 | * @param string $name |
||
169 | * @param array $arguments |
||
170 | * |
||
171 | * @return bool|object |
||
172 | * @throws BadMethodCallException |
||
173 | */ |
||
174 | public function __call(string $name, array $arguments) |
||
199 | |||
200 | /** |
||
201 | * Check if class is exist in folder |
||
202 | * |
||
203 | * @param string $name |
||
204 | * @return bool |
||
205 | */ |
||
206 | public function __isset(string $name): bool |
||
210 | |||
211 | /** |
||
212 | * Ordinary dummy setter, it should be ignored (added to PSR reasons) |
||
213 | * |
||
214 | * @param string $name |
||
215 | * @param mixed $value |
||
216 | * @throws BadMethodCallException |
||
217 | */ |
||
218 | public function __set(string $name, $value) |
||
222 | } |
||
223 |