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 ( d0216f...e7f575 )
by SignpostMarv
02:16
created

ClassReflectionExtension   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getProperty() 0 8 1
A hasProperty() 0 18 3
A setBroker() 0 3 1
1
<?php
2
/**
3
* Base daft objects.
4
*
5
* @author SignpostMarv
6
*/
7
declare(strict_types=1);
8
9
namespace SignpostMarv\DaftObject\PHPStan;
10
11
use PHPStan\Broker\Broker;
12
use PHPStan\Reflection\BrokerAwareClassReflectionExtension;
13
use PHPStan\Reflection\ClassReflection ;
14
use PHPStan\Reflection\PropertiesClassReflectionExtension;
15
use PHPStan\Reflection\PropertyReflection;
16
use PHPStan\Type\Type;
17
use SignpostMarv\DaftObject\DaftObject;
18
19
class ClassReflectionExtension implements
20
    BrokerAwareClassReflectionExtension,
21
    PropertiesClassReflectionExtension
22
{
23
    /**
24
    * @var Broker
25
    */
26
    private $broker;
27
28
    public function setBroker(Broker $broker) : void
29
    {
30
        $this->broker = $broker;
31
    }
32
33
    public function hasProperty(
34
        ClassReflection $classReflection,
35
        string $propertyName
36
    ) : bool {
37
        $className = $classReflection->getName();
38
39
        $property = ucfirst($propertyName);
40
41
        return
42
            is_a($className, DaftObject::class, true) &&
43
            (
44
                $classReflection->getNativeReflection()->hasMethod(
45
                    'Get' .
46
                    $property
47
                ) ||
48
                $classReflection->getNativeReflection()->hasMethod(
49
                    'Set' .
50
                    $property
51
                )
52
            );
53
    }
54
55
    public function getProperty(
56
        ClassReflection $classReflection,
57
        string $propertyName
58
    ) : PropertyReflection {
59
        return new PropertyReflectionExtension(
60
            $classReflection,
61
            $this->broker,
62
            $propertyName
63
        );
64
    }
65
}
66