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