Base::checkUserPermissions()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller\User;
6
7
use App\Controller\BaseController;
8
use App\Exception\UserException;
9
use App\Service\UserService;
10
use Slim\Container;
11
12
abstract class Base extends BaseController
13
{
14
    public function __construct(Container $container)
15
    {
16
        $this->container = $container;
17
    }
18
19
    protected function getUserService(): UserService
20
    {
21
        return $this->container->get('user_service');
22
    }
23
24
    protected function checkUserPermissions($userId, $userIdLogged)
25
    {
26
        if ($userId != $userIdLogged) {
27
            throw new UserException('User permission failed.', 400);
28
        }
29
    }
30
}
31