1 | <?php |
||
15 | final class StarCitizens |
||
16 | { |
||
17 | /** |
||
18 | * @var bool|StarCitizensClient The client object |
||
19 | */ |
||
20 | private static $client = false; |
||
21 | |||
22 | /** |
||
23 | * @var array The config for the StarCitizens todo move this to a separate file |
||
24 | */ |
||
25 | private $systems = []; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | public $configFile; |
||
31 | |||
32 | /** |
||
33 | * StarCitizens constructor. |
||
34 | * |
||
35 | * @param string $configFile |
||
36 | */ |
||
37 | 20 | public function __construct($configFile = "Resources/config/typesConfig.php") |
|
43 | |||
44 | /** |
||
45 | * Reads the basic config. |
||
46 | */ |
||
47 | 20 | private function readConfig() |
|
51 | |||
52 | /** |
||
53 | * Find an entity based on id and return the correct model or raw json output |
||
54 | * |
||
55 | * @param $id |
||
56 | * @param $system |
||
57 | * @param $profileType |
||
58 | * @param bool $raw |
||
59 | * @param bool $cache |
||
60 | * @return bool|mixed |
||
61 | */ |
||
62 | 19 | private function get($id, $system, $profileType, $raw = false, $cache = false) |
|
76 | |||
77 | /** |
||
78 | * Returns the params needed for an API call |
||
79 | * |
||
80 | * @param $id |
||
81 | * @param $system |
||
82 | * @param $profileType |
||
83 | * @param $cache |
||
84 | * @return array |
||
85 | */ |
||
86 | 19 | private function getCallParams($id, $system, $profileType, $cache) |
|
101 | |||
102 | /** |
||
103 | * Checks the response for success messages and returns the raw response or model |
||
104 | * |
||
105 | * @param $response |
||
106 | * @param $profileType |
||
107 | * @param $raw |
||
108 | * |
||
109 | * @return bool|mixed |
||
110 | */ |
||
111 | 19 | private function checkResponse($response, $profileType, $raw) |
|
123 | |||
124 | /** |
||
125 | * Setup the client |
||
126 | */ |
||
127 | 20 | private static function setupClient() |
|
133 | |||
134 | /** |
||
135 | * Fills our model in with the provided data or sends the data to a store |
||
136 | * |
||
137 | * @param $model |
||
138 | * @param $fillData |
||
139 | * |
||
140 | * @return Model |
||
141 | */ |
||
142 | 19 | private function fillModel($model, $fillData) |
|
153 | |||
154 | /** |
||
155 | * Magic call function based on the config information |
||
156 | * |
||
157 | * @param $name |
||
158 | * @param $arguments |
||
159 | * @return bool|mixed |
||
160 | * @throws \Exception |
||
161 | */ |
||
162 | 20 | public function __call($name, $arguments) |
|
170 | |||
171 | /** |
||
172 | * This is the real call function |
||
173 | * |
||
174 | * @param $system |
||
175 | * @param array $arguments |
||
176 | * @return bool|mixed |
||
177 | */ |
||
178 | 19 | private function doCall($system, array $arguments = []) |
|
190 | |||
191 | /** |
||
192 | * Get the standard arguments for a find call and checks that we |
||
193 | * have the correct arguments passed to the magic function |
||
194 | * |
||
195 | * @param array $arguments |
||
196 | * @return array |
||
197 | */ |
||
198 | 19 | private function standardGetArguments(array $arguments) |
|
218 | |||
219 | /** |
||
220 | * Allows our functions to be called statically, this is a bit hacky tbh. |
||
221 | * |
||
222 | * @param $name |
||
223 | * @param $arguments |
||
224 | * @return bool|mixed |
||
225 | * @throws \Exception |
||
226 | */ |
||
227 | 1 | public static function __callStatic($name, $arguments) |
|
232 | } |