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.
Completed
Push — master ( e5413e...3eb92c )
by Mario
03:50
created

Identifier::getPrimary()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 3
nc 4
nop 0
1
<?php
2
3
namespace Netgen\InformationCollection\Core\Action;
4
5
use Netgen\InformationCollection\API\Action\ActionInterface;
6
use ReflectionClass;
7
use ReflectionProperty;
8
9
final class Identifier
10
{
11
    /**
12
     * @var string
13
     */
14
    private $classConstant;
15
16
    public function __construct(ActionInterface $action)
17
    {
18
        $this->classConstant = get_class($action);
19
    }
20
21
    public function getPrimary(): string
22
    {
23
        $class = new ReflectionClass($this->classConstant);
24
        $propertyValue = '';
25
26
        if ($class->hasProperty('defaultName')) {
27
            $defaultName = new ReflectionProperty($this->classConstant, 'defaultName');
28
            $propertyValue = $defaultName->getValue();
29
        }
30
31
        if (!empty($propertyValue)) {
32
            return $propertyValue;
33
        }
34
35
        return $this->getSecondary();
36
    }
37
38
    public function getSecondary(): string
39
    {
40
        return $this->classConstant;
41
    }
42
}
43