TargetMatchEnum   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 44
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toString() 0 22 5
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 TargetMatchEnum
25
{
26
    /** @see http://docs.oasis-open.org/xacml/3.0/xacml-3.0-core-spec-os-en.html #7.11 (table 4) */
27
28
    /** Combine result */
29
    const MATCH = 0;
30
31
    /** Combine result */
32
    const NOT_MATCH =  self::MATCH + 1;
33
34
    /** Combine result */
35
    const NO_TARGET =  self::NOT_MATCH + 1;
36
37
    /** Combine result */
38
    const INDETERMINATE = self::NO_TARGET + 1;
39
40
    /**
41
     * @param int $value
42
     *
43 15
     * @return string
44
     */
45
    public static function toString(int $value): string
46 15
    {
47 8
        switch ($value) {
48 8
            case static::MATCH:
49 15
                $result = 'MATCH';
50 8
                break;
51 8
            case static::NOT_MATCH:
52 15
                $result = 'NOT MATCH';
53 9
                break;
54 9
            case static::NO_TARGET:
55 7
                $result = 'NO TARGET';
56 7
                break;
57 7
            case static::INDETERMINATE:
58
                $result = 'INDETERMINATE';
59 1
                break;
60 1
            default:
61
                $result = 'UNKNOWN';
62
                break;
63 15
        }
64
65
        return $result;
66
    }
67
}
68