Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
79.31% |
23 / 29 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
PickupCall | |
79.31% |
23 / 29 |
|
0.00% |
0 / 2 |
7.43 | |
0.00% |
0 / 1 |
readResponse | |
91.67% |
11 / 12 |
|
0.00% |
0 / 1 |
3.01 | |||
readSelectedProcess | |
70.59% |
12 / 17 |
|
0.00% |
0 / 1 |
4.41 |
1 | <?php |
2 | |
3 | /** |
4 | * @package Zmsadmin |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsadmin; |
9 | |
10 | use BO\Mellon\Validator; |
11 | |
12 | /** |
13 | * |
14 | */ |
15 | class PickupCall extends BaseController |
16 | { |
17 | /** |
18 | * @SuppressWarnings(Param) |
19 | * @return String |
20 | */ |
21 | public function readResponse( |
22 | \Psr\Http\Message\RequestInterface $request, |
23 | \Psr\Http\Message\ResponseInterface $response, |
24 | array $args |
25 | ) { |
26 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
27 | $inputNumber = Validator::value($args['id'])->isNumber()->getValue(); |
28 | $process = $this->readSelectedProcess($workstation, $inputNumber); |
29 | if ('pending' != $process->getStatus() && 'pickup' != $process->getStatus()) { |
30 | throw new Exception\Process\ProcessNotPending(); |
31 | } |
32 | $workstation->process = \App::$http->readPostResult('/process/status/pickup/', $process)->getEntity(); |
33 | |
34 | return \BO\Slim\Render::withHtml( |
35 | $response, |
36 | 'block/pickup/called.twig', |
37 | array( |
38 | 'workstation' => $workstation ) |
39 | ); |
40 | } |
41 | |
42 | protected function readSelectedProcess($workstation, $inputNumber) |
43 | { |
44 | try { |
45 | if (4 <= strlen((string)$inputNumber)) { |
46 | $process = \App::$http |
47 | ->readGetResult('/process/' . $inputNumber . '/') |
48 | ->getEntity(); |
49 | $workstation->testMatchingProcessScope($workstation->getScopeList(), $process); |
50 | } else { |
51 | $process = \App::$http |
52 | ->readGetResult('/scope/' . $workstation->scope['id'] . '/queue/' . $inputNumber . '/') |
53 | ->getEntity(); |
54 | } |
55 | } catch (\BO\Zmsclient\Exception $exception) { |
56 | if ($exception->template == 'BO\Zmsapi\Exception\Process\ProcessByQueueNumberNotFound') { |
57 | $process = new \BO\Zmsentities\Process(); |
58 | $process->scope['id'] = $workstation->scope['id']; |
59 | $process->queue['number'] = $inputNumber; |
60 | $process->amendment = 'Über die direkte Nummerneingabe angelegter Abholer.'; |
61 | $process = \App::$http->readPostResult('/process/status/pickup/', $process)->getEntity(); |
62 | } else { |
63 | throw $exception; |
64 | } |
65 | } |
66 | return $process; |
67 | } |
68 | } |