ControllerDefaultTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 18
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __isAuthorized() 0 3 1
A __unauthorized() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Utilities\Router\Traits;
5
6
use Utilities\Router\Response;
7
use Utilities\Router\Utils\StatusCode;
8
9
/**
10
 * ControllerDefaultTrait class
11
 *
12
 * @link    https://github.com/utilities-php/router
13
 * @author  Shahrad Elahi (https://github.com/shahradelahi)
14
 * @license https://github.com/utilities-php/router/blob/master/LICENSE (MIT License)
15
 */
16
trait ControllerDefaultTrait
17
{
18
19
    /**
20
     * @return bool
21
     */
22
    public function __isAuthorized(): bool
23
    {
24
        return true;
25
    }
26
27
    /**
28
     * @return void
29
     */
30
    public function __unauthorized(): void
31
    {
32
        Response::send(StatusCode::UNAUTHORIZED, [
33
            'message' => 'Unauthorized: You are not authorized to access this resource.'
34
        ]);
35
    }
36
37
}