BaseAllowedValues   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getConstants() 0 4 1
A constants() 0 4 1
A isValid() 0 4 1
1
<?php
2
3
namespace WSW\SiftScience\Support\AllowedValues;
4
5
use ReflectionClass;
6
7
/**
8
 * Class BaseAllowedValues
9
 *
10
 * @package WSW\SiftScience\Support\AllowedValues
11
 * @author Ronaldo Matos Rodrigues <[email protected]>
12
 */
13
abstract class BaseAllowedValues
14
{
15
    /**
16
     * @return array
17
     */
18 3
    public static function getConstants()
19
    {
20 3
        return static::constants();
21
    }
22
23
    /**
24
     * @return array
25
     */
26 21
    protected static function constants()
27
    {
28 21
        return (new ReflectionClass(get_called_class()))->getConstants();
29
    }
30
31
    /**
32
     * @param string $value
33
     *
34
     * @return bool
35
     */
36 19
    public static function isValid($value)
37
    {
38 19
        return in_array($value, static::constants());
39
    }
40
}
41