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 ( fb2cf2...a0a09f )
by Baptiste
02:11
created

ReflectionStrategy::extract()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 21
Code Lines 11

Duplication

Lines 21
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 4
Metric Value
dl 21
loc 21
ccs 11
cts 11
cp 1
rs 9.0534
cc 4
eloc 11
nc 5
nop 2
crap 4
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Reflection\ExtractionStrategy;
5
6
use Innmind\Reflection\ExtractionStrategyInterface;
7
use Innmind\Reflection\Exception\LogicException;
8
9 View Code Duplication
class ReflectionStrategy implements ExtractionStrategyInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14 5
    public function supports($object, string $property): bool
15
    {
16 5
        $refl = new \ReflectionObject($object);
17
18 5
        return $refl->hasProperty($property);
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 3
    public function extract($object, string $property)
25
    {
26 3
        if (!$this->supports($object, $property)) {
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 1
            $refl->setAccessible(true);
35
        }
36
37 2
        $value = $refl->getValue($object);
38
39 2
        if (!$refl->isPublic()) {
40 1
            $refl->setAccessible(false);
41
        }
42
43 2
        return $value;
44
    }
45
}
46