GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AbstractEnum   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 54
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A keys() 0 4 1
A values() 0 11 2
A hasValue() 0 4 1
A checkValue() 0 8 2
1
<?php
2
3
namespace Onend\PayPal\Common\Enum;
4
5
abstract class AbstractEnum
6
{
7
    /**
8
     * @var array
9
     */
10
    protected static $cache = [];
11
12
    /**
13
     * @return string[]
0 ignored issues
show
Documentation introduced by
Should the return type not be integer[]?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
14
     */
15
    public static function keys()
16
    {
17
        return array_keys(static::values());
18
    }
19
20
    /**
21
     * @return string[]
22
     */
23
    public static function values()
24
    {
25
        $class = get_called_class();
26
27
        if (!isset(self::$cache[$class])) {
28
            $reflected = new \ReflectionClass($class);
29
            self::$cache[$class] = $reflected->getConstants();
30
        }
31
32
        return self::$cache[$class];
33
    }
34
35
    /**
36
     * @param string $value
37
     *
38
     * @return bool
39
     */
40
    public static function hasValue($value)
41
    {
42
        return in_array($value, static::values());
43
    }
44
45
    /**
46
     * @throws \InvalidArgumentException
47
     *
48
     * @param string $value
49
     */
50
    public static function checkValue($value)
51
    {
52
        if (!static::hasValue($value)) {
53
            throw new \InvalidArgumentException(
54
                sprintf('The value [%s] not exists in enum [%s]', $value, get_called_class())
55
            );
56
        }
57
    }
58
}
59