Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| DayoffList | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package ZMS API |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsapi; |
| 9 | |
| 10 | use BO\Slim\Render; |
| 11 | use BO\Zmsdb\DayOff as Query; |
| 12 | |
| 13 | class DayoffList extends BaseController |
| 14 | { |
| 15 | /** |
| 16 | * @SuppressWarnings(Param) |
| 17 | * @return String |
| 18 | */ |
| 19 | public function readResponse( |
| 20 | \Psr\Http\Message\RequestInterface $request, |
| 21 | \Psr\Http\Message\ResponseInterface $response, |
| 22 | array $args |
| 23 | ) { |
| 24 | (new Helper\User($request))->checkRights('superuser'); |
| 25 | if ($args['year'] > \App::$now->modify('+ 10years')->format('Y') || $args['year'] < \App::$now->format('Y')) { |
| 26 | throw new Exception\Dayoff\YearOutOfRange(); |
| 27 | } |
| 28 | $dayOffList = (new Query())->readCommonByYear($args['year']); |
| 29 | |
| 30 | $message = Response\Message::create($request); |
| 31 | $message->data = $dayOffList; |
| 32 | |
| 33 | $response = Render::withLastModified($response, time(), '0'); |
| 34 | $response = Render::withJson($response, $message, 200); |
| 35 | return $response; |
| 36 | } |
| 37 | } |