Test Failed
Push — main ( ea931b...8f4107 )
by Bingo
06:03
created

SystemPermissions   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 14
eloc 28
c 1
b 0
f 0
dl 0
loc 71
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 6 2
A __construct() 0 4 1
A all() 0 6 2
A set() 0 6 2
A getTypes() 0 3 1
A resources() 0 6 2
A none() 0 6 2
A delete() 0 6 2
1
<?php
2
3
namespace Jabe\Engine\Authorization;
4
5
use Jabe\Engine\Authorization\Exception\PermissionNotFound;
6
7
class SystemPermissions implements PermissionInterface
8
{
9
    use PermissionTrait;
10
11
    private static $NONE;
12
13
    public static function none(): PermissionInterface
14
    {
15
        if (self::$NONE === null) {
16
            self::$NONE = new ProcessDefinitionPermissions("NONE", 0);
17
        }
18
        return self::$NONE;
19
    }
20
21
    private static $ALL;
22
23
    public static function all(): PermissionInterface
24
    {
25
        if (self::$ALL === null) {
26
            self::$ALL = new SystemPermissions("ALL", PHP_INT_MAX);
27
        }
28
        return self::$ALL;
29
    }
30
31
    private static $READ;
32
33
    public static function read(): PermissionInterface
34
    {
35
        if (self::$READ === null) {
36
            self::$READ = new SystemPermissions("READ", 2);
37
        }
38
        return self::$READ;
39
    }
40
41
    private static $SET;
42
43
    public static function set(): PermissionInterface
44
    {
45
        if (self::$SET === null) {
46
            self::$SET = new SystemPermissions("SET", 4);
47
        }
48
        return self::$SET;
49
    }
50
51
    private static $DELETE;
52
53
    public static function delete(): PermissionInterface
54
    {
55
        if (self::$DELETE === null) {
56
            self::$DELETE = new SystemPermissions("DELETE", 8);
57
        }
58
        return self::$DELETE;
59
    }
60
61
    public static function resources(): array
62
    {
63
        if (self::$RESOURCES === null) {
64
            self::$RESOURCES = [ Resources::system() ];
0 ignored issues
show
Bug Best Practice introduced by
The property RESOURCES does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
65
        }
66
        return self::$RESOURCES;
67
    }
68
69
    public function getTypes(): array
70
    {
71
        return self::resources();
72
    }
73
74
    private function __construct(string $name, int $id)
75
    {
76
        $this->name = $name;
77
        $this->id = $id;
78
    }
79
}
80