Total Complexity | 5 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class LoqateApi |
||
11 | { |
||
12 | protected string $key; |
||
13 | |||
14 | /** |
||
15 | * LoqateApi constructor. |
||
16 | * |
||
17 | * @param string $key |
||
18 | */ |
||
19 | 2 | public function __construct(string $key) |
|
20 | { |
||
21 | 2 | $this->key = $key; |
|
22 | } |
||
23 | |||
24 | /** |
||
25 | * Initialise api class |
||
26 | * |
||
27 | * @param string $abstract - Class name |
||
28 | * @param string|null $key - Optional api key if you need override default key |
||
29 | * |
||
30 | * @return AbstractAPI |
||
31 | */ |
||
32 | 2 | public function api(string $abstract, ?string $key = null): AbstractAPI |
|
33 | { |
||
34 | 2 | if (!is_subclass_of($abstract, AbstractAPI::class)) { |
|
35 | 1 | throw new LoqateException('$abstract should be child of AbstractAPI'); |
|
36 | } |
||
37 | |||
38 | 2 | return new $abstract($key ?? $this->key); |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param string|null $key |
||
43 | * |
||
44 | * @return CaptureInteractiveFind |
||
45 | */ |
||
46 | 2 | public function captureInteractiveFind(?string $key = null): CaptureInteractiveFind |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param string|null $key |
||
53 | * |
||
54 | * @return CaptureInteractiveRetrieve |
||
55 | */ |
||
56 | 1 | public function captureInteractiveRetrieve(?string $key = null): CaptureInteractiveRetrieve |
|
59 | } |
||
60 | } |
||
61 |