Test Setup Failed
Push — master ( 948172...201d68 )
by Fernando
05:02
created

Base::getAndValidateUserId()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller\Task;
6
7
use App\Controller\BaseController;
8
use App\Exception\TaskException;
9
use App\Service\Task\TaskService;
10
11
abstract class Base extends BaseController
12
{
13
    protected function getTaskService(): TaskService
14
    {
15
        return $this->container->get('task_service');
16 8
    }
17
18 8
    protected function getAndValidateUserId(array $input): int
19
    {
20
        if (isset($input['decoded']) && isset($input['decoded']->sub)) {
21 4
            return (int) $input['decoded']->sub;
22
        }
23 4
24
        throw new TaskException('Invalid task. Permission failed.', 400);
25
    }
26
}
27