Total Complexity | 6 |
Total Lines | 88 |
Duplicated Lines | 0 % |
Coverage | 73.32% |
Changes | 0 |
1 | <?php |
||
10 | abstract class AbstractApi implements IApi |
||
11 | { |
||
12 | |||
13 | use \App\Reuse\Controllers\Api\TFileCache; |
||
14 | |||
15 | /** |
||
16 | * request |
||
17 | * |
||
18 | * @var Request |
||
19 | */ |
||
20 | protected $request; |
||
21 | |||
22 | /** |
||
23 | * response |
||
24 | * |
||
25 | * @var Response |
||
26 | */ |
||
27 | protected $response; |
||
28 | |||
29 | /** |
||
30 | * di container |
||
31 | * |
||
32 | * @var Container |
||
33 | */ |
||
34 | private $container; |
||
35 | |||
36 | /** |
||
37 | * instanciate |
||
38 | * |
||
39 | */ |
||
40 | 4 | public function __construct(Container $container) |
|
41 | { |
||
42 | 4 | $this->container = $container; |
|
43 | 4 | $this->request = $this->getService(\App\Http\Request::class); |
|
44 | 4 | $this->response = $this->getService(\App\Http\Response::class); |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * preflight CORS with OPTIONS method |
||
49 | * |
||
50 | * @Methods OPTIONS |
||
51 | * @return IApi |
||
52 | */ |
||
53 | 1 | public function preflight(): IApi |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * returns container service from a service name |
||
61 | * |
||
62 | * @param string $serviceName |
||
63 | * @return object |
||
64 | */ |
||
65 | 1 | protected function getService(string $serviceName) |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * return container instance |
||
72 | * |
||
73 | * @return Container |
||
74 | */ |
||
75 | 1 | protected function getContainer(): Container |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * get request instance |
||
82 | * |
||
83 | * @return Request |
||
84 | */ |
||
85 | protected function getRequest(): Request |
||
86 | { |
||
87 | return $this->request; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * get request params |
||
92 | * |
||
93 | * @return array |
||
94 | */ |
||
95 | protected function getParams(): array |
||
98 | } |
||
99 | } |
||
100 |