EvaluationEnum   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 62
ccs 26
cts 26
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B toString() 0 31 8
1
<?php declare(strict_types=1);
2
3
namespace Limoncello\Auth\Contracts\Authorization\PolicyAdministration;
4
5
/**
6
 * Copyright 2015-2019 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
/**
22
 * @package Limoncello\Auth
23
 */
24
abstract class EvaluationEnum
25
{
26
    /** @see http://docs.oasis-open.org/xacml/3.0/xacml-3.0-core-spec-os-en.html#_Toc325047187 */
27
28
    /** Combine result */
29
    const PERMIT = (1 << 0);
30
31
    /** Combine result */
32
    const DENY =  (1 << 1);
33
34
    /** Combine result */
35
    const INDETERMINATE = (1 << 2);
36
37
    /** Combine result */
38
    const NOT_APPLICABLE = (1 << 3);
39
40
    /** Combine result */
41
    const INDETERMINATE_PERMIT = self::INDETERMINATE | self::PERMIT;
42
43
    /** Combine result */
44
    const INDETERMINATE_DENY = self::INDETERMINATE | self::DENY;
45
46
    /** Combine result */
47
    const INDETERMINATE_DENY_OR_PERMIT = self::INDETERMINATE | self::DENY | self::PERMIT;
48
49
    /**
50
     * @param int $value
51
     *
52 14
     * @return string
53
     */
54 14
    public static function toString(int $value): string
55
    {
56
        switch ($value) {
57 14
            case static::PERMIT:
58 7
                $result = 'PERMIT';
59 7
                break;
60 12
            case static::DENY:
61 2
                $result = 'DENY';
62 2
                break;
63 12
            case static::INDETERMINATE:
64 2
                $result = 'INDETERMINATE';
65 2
                break;
66 12
            case static::NOT_APPLICABLE:
67 5
                $result = 'NOT APPLICABLE';
68 5
                break;
69 7
            case static::INDETERMINATE_PERMIT:
70 3
                $result = 'INDETERMINATE PERMIT';
71 3
                break;
72 5
            case static::INDETERMINATE_DENY:
73 3
                $result = 'INDETERMINATE DENY';
74 3
                break;
75 3
            case static::INDETERMINATE_DENY_OR_PERMIT:
76 3
                $result = 'INDETERMINATE DENY OR PERMIT';
77 3
                break;
78
            default:
79 1
                $result = 'UNKNOWN';
80 1
                break;
81
        }
82
83 14
        return $result;
84
    }
85
}
86