1 | <?php |
||
31 | class HubicService implements SingletonInterface |
||
32 | { |
||
33 | const AUTHORIZATION_ENDPOINT = 'https://api.hubic.com/oauth/auth/'; |
||
34 | |||
35 | const TOKEN_ENDPOINT = 'https://api.hubic.com/oauth/token/'; |
||
36 | |||
37 | const DOMAIN_API = 'https://api.hubic.com/'; |
||
38 | |||
39 | const VERSION_API = '1.0'; |
||
40 | |||
41 | /** |
||
42 | * @var RequestFactory |
||
43 | */ |
||
44 | protected $requestFactory; |
||
45 | |||
46 | /** |
||
47 | * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager |
||
48 | */ |
||
49 | protected $persistenceManager; |
||
50 | |||
51 | /** |
||
52 | * @var \Filoucrackeur\Hubic\Domain\Repository\AccountRepository |
||
53 | */ |
||
54 | protected $accountRepository; |
||
55 | |||
56 | /** |
||
57 | * @var \Filoucrackeur\Hubic\Domain\Model\Account |
||
58 | */ |
||
59 | protected $account; |
||
60 | |||
61 | /** |
||
62 | * @param Account $account |
||
63 | * |
||
64 | * @return bool |
||
65 | * @throws \RuntimeException |
||
66 | */ |
||
67 | public function accessToken(Account $account) |
||
97 | |||
98 | /** |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getHost(): string |
||
105 | |||
106 | /** |
||
107 | * @param Account $account |
||
108 | */ |
||
109 | public function redirectUrlRequestToken(Account $account) |
||
123 | |||
124 | /** |
||
125 | * @param Account $account |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | private function getRedirectUri(Account $account): string |
||
147 | |||
148 | public function getAccount() |
||
152 | |||
153 | /** |
||
154 | * @param Account $account |
||
155 | */ |
||
156 | public function setAccount(Account $account) |
||
160 | |||
161 | /** |
||
162 | * @param string $path |
||
163 | * @param string $method |
||
164 | * @param array $arguments |
||
165 | * @return \Psr\Http\Message\ResponseInterface|string |
||
166 | */ |
||
167 | public function fetch(string $path, $method = 'GET', array $arguments = []) |
||
195 | |||
196 | /** |
||
197 | * @param Account $account |
||
198 | * @return bool |
||
199 | */ |
||
200 | public function refreshToken(Account $account): bool |
||
227 | |||
228 | /** |
||
229 | * @param Account $account |
||
230 | */ |
||
231 | public function delete(Account $account): void |
||
236 | |||
237 | /** |
||
238 | * @param Account $account |
||
239 | */ |
||
240 | public function unlink(Account $account): void |
||
247 | |||
248 | /** |
||
249 | * @return QueryResult|null |
||
250 | */ |
||
251 | public function getAccounts() |
||
255 | |||
256 | /** |
||
257 | * Get hubiC account Quota. |
||
258 | * |
||
259 | * @see https://api.hubic.com/console/ |
||
260 | * |
||
261 | * @return ResponseInterface|null |
||
262 | */ |
||
263 | public function getAccountQuota() |
||
267 | |||
268 | /** |
||
269 | * Get hubiC agreements. |
||
270 | * |
||
271 | * @see https://api.hubic.com/console/ |
||
272 | * |
||
273 | * @return ResponseInterface|null |
||
274 | */ |
||
275 | public function getAgreement() |
||
279 | |||
280 | /** |
||
281 | * Get hubiC getAllLinks. |
||
282 | * |
||
283 | * @see https://api.hubic.com/console/ |
||
284 | * |
||
285 | * @return ResponseInterface|null |
||
286 | */ |
||
287 | public function getAllLinks() |
||
291 | |||
292 | /** |
||
293 | * Delete hubiC link. |
||
294 | * |
||
295 | * @see https://api.hubic.com/console/ |
||
296 | * |
||
297 | * @param string $uri |
||
298 | * @return ResponseInterface|null |
||
299 | */ |
||
300 | public function deleteLink(string $uri) |
||
305 | |||
306 | /** |
||
307 | * @param RequestFactory $requestFactory |
||
308 | */ |
||
309 | public function injectRequestFactory(RequestFactory $requestFactory): void |
||
313 | |||
314 | /** |
||
315 | * @param PersistenceManager $persistenceManager |
||
316 | */ |
||
317 | public function injectPersistenceManager(PersistenceManager $persistenceManager): void |
||
321 | |||
322 | /** |
||
323 | * @param AccountRepository $accountRepository |
||
324 | */ |
||
325 | public function injectAccountRepository(AccountRepository $accountRepository): void |
||
329 | } |
||
330 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.