Delete::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 12
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller\User;
6
7
use Slim\Http\Request;
8
use Slim\Http\Response;
9
10
final class Delete extends Base
11
{
12 2
    /**
13
     * @param array<string> $args
14 2
     */
15 2
    public function __invoke(
16 2
        Request $request,
17 1
        Response $response,
18
        array $args
19 1
    ): Response {
20
        $input = (array) $request->getParsedBody();
21
        $userIdLogged = (int) $this->getAndValidateUserId($input);
22
        $id = (int) $args['id'];
23
        $this->checkUserPermissions($id, $userIdLogged);
24
        $this->getServiceDeleteUser()->delete($id);
25
26
        return $this->jsonResponse($response, 'success', null, 204);
27
    }
28
}
29