|
27 | 27 | /** |
28 | 28 | * @phpstan-type AccessToken array{access_token: string, token_type: string, expires_in: int, refresh_token: string} |
29 | 29 | * @phpstan-type ServiceIndex array<string, array{href: string, title: string}> |
30 | | - */ |
| 30 | + * @phpstan-type OptionsInput array{ |
| 31 | + * api_uri: non-empty-string, |
| 32 | + * api_username: non-empty-string, |
| 33 | + * api_secret: non-empty-string, |
| 34 | + * f2_username: non-empty-string, |
| 35 | + * cache_item_pool: CacheItemPoolInterface, |
| 36 | + * cache_item_lifetime?: int, |
| 37 | + * } |
| 38 | + * @phpstan-type Options array{ |
| 39 | + * api_uri: non-empty-string, |
| 40 | + * api_username: non-empty-string, |
| 41 | + * api_secret: non-empty-string, |
| 42 | + * f2_username: non-empty-string, |
| 43 | + * cache_item_pool: CacheItemPoolInterface, |
| 44 | + * cache_item_lifetime: int, |
| 45 | + * }*/ |
31 | 46 | class ApiClient |
32 | 47 | { |
33 | 48 | use LoggerAwareTrait; |
34 | 49 | use LoggerTrait; |
35 | 50 |
|
| 51 | + /** @var Options */ |
36 | 52 | private readonly array $options; |
| 53 | + |
37 | 54 | private ?HttpClientInterface $client = null; |
38 | 55 |
|
| 56 | + /** |
| 57 | + * @param OptionsInput $options |
| 58 | + */ |
39 | 59 | public function __construct(array $options) |
40 | 60 | { |
41 | 61 | $resolver = new OptionsResolver(); |
@@ -68,7 +88,7 @@ public function getServiceIndex(): array |
68 | 88 | ], |
69 | 89 | ]); |
70 | 90 |
|
71 | | - /** @var ServiceIndex */ |
| 91 | + /* @var ServiceIndex */ |
72 | 92 | return $response->toArray(); |
73 | 93 | }); |
74 | 94 | } |
@@ -140,6 +160,9 @@ public function caseCreate(array $caseData): CaseFile |
140 | 160 | return $this->createItemResult($response, CaseFile::class); |
141 | 161 | } |
142 | 162 |
|
| 163 | + /** |
| 164 | + * @return Atom[] |
| 165 | + */ |
143 | 166 | public function matterSearch(string $searchTerms, int $count = 10): array |
144 | 167 | { |
145 | 168 | $query = [ |
@@ -366,10 +389,10 @@ protected function configureOptions(OptionsResolver $resolver): void |
366 | 389 | 'api_secret', |
367 | 390 | 'f2_username', |
368 | 391 | ]) |
369 | | - ->setDefault('cache_item_lifetime', 86_400) |
370 | | - ->setAllowedTypes('cache_item_lifetime', 'int') |
371 | 392 | ->setRequired('cache_item_pool') |
372 | | - ->setAllowedTypes('cache_item_pool', CacheItemPoolInterface::class); |
| 393 | + ->setAllowedTypes('cache_item_pool', CacheItemPoolInterface::class) |
| 394 | + ->setDefault('cache_item_lifetime', 86_400) |
| 395 | + ->setAllowedTypes('cache_item_lifetime', 'int'); |
373 | 396 | } |
374 | 397 |
|
375 | 398 | protected function getRequestUrl(string $rel, array $values = []): string |
@@ -468,7 +491,7 @@ protected function createItemResult(ResponseInterface $response, string $class): |
468 | 491 | { |
469 | 492 | $item = new \SimpleXMLElement($response->getContent()); |
470 | 493 |
|
471 | | - /** @var T */ |
| 494 | + /* @var T */ |
472 | 495 | return $class::fromSimpleXMLElement($item); |
473 | 496 | } |
474 | 497 |
|
|
0 commit comments