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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPrimary() 0 16 3
A getSecondary() 0 4 1
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