Lines 100.00% 17 / 17
Methods 100.00% 3 / 3
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 readResponse 100.00% 10 / 10 100.00% 1 / 1 1
 testEntity 100.00% 4 / 4 100.00% 1 / 1 2
 [BO\Zmsbackend\Api\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
15class SourceUpdate extends \BO\Zmsbackend\Api\BaseController
16{
17    /**
18     * @SuppressWarnings(Param)
19     * @return \Psr\Http\Message\ResponseInterface
20     */
21    #[\Override]
22    public function readResponse(
23        \Psr\Http\Message\RequestInterface $request,
24        \Psr\Http\Message\ResponseInterface $response,
25        array $args
26    ) {
27        (new \BO\Zmsbackend\Helper\User($request))->checkPermissions('source');
28        $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(0)->getValue();
29        $input = Validator::input()->isJson()->assertValid()->getValue();
30
31        $entity = new Entity($input);
32        $this->testEntity($entity, $input);
33
34        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
35        $message->data = (new Query())->writeEntity($entity, $resolveReferences);
36
37        $response = Render::withLastModified($response, time(), '0');
38        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
39        return $response;
40    }
41
42    /**
43     * @return void
44     */
45    protected function testEntity(Entity $entity, $input)
46    {
47        try {
48            $entity->testValid('de_DE', 1);
49        } catch (\Exception $exception) {
50            $exception->data['input'] = $input;
51            throw $exception;
52        }
53    }
54}

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    }