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 — develop ( 6d95b6...ad64b7 )
by Baptiste
02:31
created

ReflectionStrategy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 35
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 6 1
A inject() 0 19 4
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Reflection\InjectionStrategy;
5
6
use Innmind\Reflection\InjectionStrategyInterface;
7
use Innmind\Reflection\Exception\LogicException;
8
9
class ReflectionStrategy implements InjectionStrategyInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14 6
    public function supports($object, string $property, $value): bool
15
    {
16 6
        $refl = new \ReflectionObject($object);
17
18 6
        return $refl->hasProperty($property);
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 3
    public function inject($object, string $property, $value)
25
    {
26 3
        if (!$this->supports($object, $property, $value)) {
27 1
            throw new LogicException;
28
        }
29
30 2
        $refl = new \ReflectionObject($object);
31 2
        $refl = $refl->getProperty($property);
32
33 2
        if (!$refl->isPublic()) {
34 2
            $refl->setAccessible(true);
35
        }
36
37 2
        $refl->setValue($object, $value);
38
39 2
        if (!$refl->isPublic()) {
40 2
            $refl->setAccessible(false);
41
        }
42 2
    }
43
}
44