Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RoleDelete
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace BO\Zmsadmin;
4
5use BO\Mellon\Validator;
6use BO\Zmsentities\Exception\UserAccountMissingRights;
7
8class RoleDelete extends BaseController
9{
10    /**
11     * @return \Psr\Http\Message\ResponseInterface
12     */
13    public function readResponse(
14        \Psr\Http\Message\RequestInterface $request,
15        \Psr\Http\Message\ResponseInterface $response,
16        array $args
17    ) {
18        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
19        if (!$workstation->getUseraccount()->hasPermissions(['superuser'])) {
20            throw new UserAccountMissingRights();
21        }
22
23        $roleId = (int) Validator::value($args['id'] ?? null)->isNumber()->getValue();
24        \App::$http->readDeleteResult('/roles/' . $roleId . '/', [])->getEntity();
25
26        return $response->withStatus(204);
27    }
28}