Passed
Push — master ( f70274...15da4f )
by Константин
08:58
created

EnumMethodReflection   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A isStatic() 0 3 1
A getPrototype() 0 3 1
A getDeclaringClass() 0 3 1
A getName() 0 3 1
A isPrivate() 0 3 1
A __construct() 0 4 1
A getVariants() 0 3 1
A isPublic() 0 3 1
1
<?php
2
3
namespace Grachevko\Enum\PHPStan;
4
5
use Grachevko\Enum\Utils;
6
use PHPStan\Reflection\ClassMemberReflection;
7
use PHPStan\Reflection\ClassReflection;
8
use PHPStan\Reflection\MethodReflection;
9
10
/**
11
 * @author Konstantin Grachev <[email protected]>
12
 */
13
final class EnumMethodReflection implements MethodReflection
14
{
15
    /**
16
     * @var ClassReflection
17
     */
18
    private $classReflection;
19
20
    /**
21
     * @var string
22
     */
23
    private $name;
24
25
    public function __construct(ClassReflection $classReflection, string $methodName)
26
    {
27
        $this->classReflection = $classReflection;
28
        $this->name = $methodName;
29
    }
30
31
    public function getVariants(): array
32
    {
33
        return [];
34
    }
35
36
    public function getDeclaringClass(): ClassReflection
37
    {
38
        return $this->classReflection;
39
    }
40
41
    public function isStatic(): bool
42
    {
43
        return $this->classReflection->getNativeReflection()->hasConstant(Utils::stringToConstant($this->name));
44
    }
45
46
    public function isPrivate(): bool
47
    {
48
        return false;
49
    }
50
51
    public function isPublic(): bool
52
    {
53
        return true;
54
    }
55
56
    public function getPrototype(): ClassMemberReflection
57
    {
58
        return $this;
59
    }
60
61
    public function getName(): string
62
    {
63
        return $this->name;
64
    }
65
}
66