BaseAllowedValues::isValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 1
cc 1
eloc 2
nc 1
nop 1
crap 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