| Total Complexity | 4 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| 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 | public function __construct(Container $container) |
||
| 41 | { |
||
| 42 | $this->container = $container; |
||
| 43 | $this->request = $this->getService(\App\Http\Request::class); |
||
| 44 | $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 | 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 | protected function getService(string $serviceName) |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * return container instance |
||
| 72 | * |
||
| 73 | * @return Container |
||
| 74 | */ |
||
| 75 | protected function getContainer(): Container |
||
| 78 | } |
||
| 79 | } |
||
| 80 |