Base   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 19
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getUserService() 0 4 1
A checkUserPermissions() 0 6 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