Lines 100.00% 17 / 17
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 readResponse 100.00% 14 / 14 100.00% 1 / 1 2
 [BO\Zmsbackend\Api\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
16class OrganisationDelete extends \BO\Zmsbackend\Api\BaseController
17{
18    /**
19     * @SuppressWarnings(Param)
20     * @return \Psr\Http\Message\ResponseInterface
21     */
22    #[\Override]
23    public function readResponse(
24        \Psr\Http\Message\RequestInterface $request,
25        \Psr\Http\Message\ResponseInterface $response,
26        array $args
27    ) {
28        $query = new Query();
29        $organisation = $query->readEntity($args['id'], 1);
30        if (! $organisation) {
31            throw new \BO\Zmsbackend\Organisation\Exception\OrganisationNotFound();
32        }(new \BO\Zmsbackend\Helper\User($request, 2))->checkPermissions(
33            'organisation',
34            new \BO\Zmsentities\Useraccount\EntityAccess($organisation)
35        );
36        $query->deleteEntity($organisation->id);
37
38        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
39        $message->data = $organisation;
40
41        $response = Render::withLastModified($response, time(), '0');
42        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
43        return $response;
44    }
45}

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    }