Lines
87.50%
7 / 8
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| AvailabilityCheckDayOff | 87.50% | 7 / 8 | 0.00% | 0 / 1 | 3.02 | 0.00% | 0 / 1 | |||
| readResponse | 87.50% | 7 / 8 | 0.00% | 0 / 1 | 3.02 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsadmin\Helper; | |
| 4 | ||
| 5 | use BO\Slim\Render; | |
| 6 | use BO\Zmsadmin\BaseController; | |
| 7 | use BO\Zmsadmin\Exception\BadRequest; | |
| 8 | use BO\Zmsentities\Collection\AvailabilityList; | |
| 9 | use Psr\Http\Message\RequestInterface; | |
| 10 | use Psr\Http\Message\ResponseInterface; | |
| 11 | ||
| 12 | class AvailabilityCheckDayOff extends BaseController | |
| 13 | { | |
| 14 | /** | |
| 15 | * @return ResponseInterface | |
| 16 | */ | |
| 17 | #[\Override] | |
| 18 | public function readResponse( | |
| 19 | RequestInterface $request, | |
| 20 | ResponseInterface $response, | |
| 21 | array $args | |
| 22 | ) { | |
| 23 | $validator = $request->getAttribute('validator'); | |
| 24 | $input = $validator->getInput()->isJson()->assertValid()->getValue(); | |
| 25 | ||
| 26 | if (!isset($input['availabilityList']) || !is_array($input['availabilityList'])) { | |
| 27 | throw new BadRequest(); | |
| 28 | } | |
| 29 | ||
| 30 | $collection = (new AvailabilityList())->addData($input['availabilityList']); | |
| 31 | ||
| 32 | return Render::withJson($response, [ | |
| 33 | 'overridesDayOff' => $collection->hasDayOffOverride() | |
| 34 | ]); | |
| 35 | } | |
| 36 | } |