Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
WarehousePeriodListGet | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
2 |
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\Mellon\Validator; |
12 | |
13 | class WarehousePeriodListGet 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('scope'); |
25 | $validator = $request->getAttribute('validator'); |
26 | $period = $validator->getParameter('period')->isString()->isBiggerThan(2)->setDefault('month')->getValue(); |
27 | $subject = Validator::value($args['subject'])->isString()->getValue(); |
28 | $subjectId = Validator::value($args['subjectId'])->isNumber()->getValue(); |
29 | $exchangeClass = '\BO\Zmsdb\Exchange' . ucfirst($subject); |
30 | if (! class_exists($exchangeClass)) { |
31 | throw new Exception\Warehouse\UnknownReportType(); |
32 | } |
33 | $subjectPeriodList = (new $exchangeClass())->readPeriodList($subjectId, $period); |
34 | |
35 | $message = Response\Message::create($request); |
36 | $message->data = $subjectPeriodList; |
37 | |
38 | $response = Render::withLastModified($response, time(), '0'); |
39 | $response = Render::withJson($response, $message, $message->getStatuscode()); |
40 | return $response; |
41 | } |
42 | } |