Lines
95.23%
20 / 21
Methods
66.66%
2 / 3
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| readResponse | 91.66% | 11 / 12 | 0.00% | 0 / 1 | 4.01 | ||
| testMatching | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 4 | ||
| [BO\Zmsbackend\Api\BaseController] __invoke | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | ||
| 14 | class SessionUpdate extends \BO\Zmsbackend\Api\BaseController | |
| 15 | { | |
| 16 | /** | |
| 17 | * @SuppressWarnings(Param) | |
| 18 | * @return \Psr\Http\Message\ResponseInterface | |
| 19 | */ | |
| 20 | #[\Override] | |
| 21 | public function readResponse( | |
| 22 | \Psr\Http\Message\RequestInterface $request, | |
| 23 | \Psr\Http\Message\ResponseInterface $response, | |
| 24 | array $args | |
| 25 | ) { | |
| 26 | $input = Validator::input()->isJson()->assertValid()->getValue(); | |
| 27 | $session = new \BO\Zmsentities\Session($input); | |
| 28 | //overwrite sessions content without frontend parameter like basket and human | |
| 29 | if (Validator::param('oidc')->isBool()->setDefault(false)->getValue()) { | |
| 30 | $session->content = $input['content']; | |
| 31 | } | |
| 32 | $session->testValid(); | |
| 33 | if (isset($session->getContent()['error']) && 'isDifferent' != $session->getContent()['error']) { | |
| 34 | $this->testMatching($session); | |
| 35 | } | |
| 36 | ||
| 37 | $message = \BO\Zmsbackend\Api\Response\Message::create($request); | |
| 38 | $message->data = (new \BO\Zmsbackend\Session\Service\Session())->updateEntity($session); | |
| 39 | ||
| 40 | $response = Render::withLastModified($response, time(), '0'); | |
| 41 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); | |
| 42 | return $response; | |
| 43 | } | |
| 44 | ||
| 45 | /** | |
| 46 | * @return void | |
| 47 | */ | |
| 48 | protected function testMatching(\BO\Zmsentities\Session $session) | |
| 49 | { | |
| 50 | if (false === \BO\Zmsbackend\Helper\Matching::isProviderExisting($session)) { | |
| 51 | throw new \BO\Zmsbackend\Matching\Exception\ProviderNotFound(); | |
| 52 | } elseif (false === \BO\Zmsbackend\Helper\Matching::isRequestExisting($session)) { | |
| 53 | throw new \BO\Zmsbackend\Matching\Exception\RequestNotFound(); | |
| 54 | } elseif (false === \BO\Zmsbackend\Helper\Matching::hasProviderRequest($session)) { | |
| 55 | throw new \BO\Zmsbackend\Matching\Exception\MatchingNotFound(); | |
| 56 | } | |
| 57 | } | |
| 58 | } |
Inherited from BO\Zmsbackend\Api\BaseController
| 20 | public function __invoke(RequestInterface $request, ResponseInterface $response, array $args) | |
| 21 | { | |
| 22 | $request = $this->initRequest($request); | |
| 23 | $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0'); | |
| 24 | return $this->readResponse($request, $noCacheResponse, $args); | |
| 25 | } |