ControllerDefaultTrait::__isAuthorized()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
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
}