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 ( f00018...f19ece )
by Baptiste
02:02
created

ReflectionStrategy::extract()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 20
Code Lines 10

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
dl 20
loc 20
c 0
b 0
f 0
ccs 10
cts 10
cp 1
rs 9.2
cc 4
eloc 10
nc 5
nop 2
crap 4
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Reflection\ExtractionStrategy;
5
6
use Innmind\Reflection\{
7
    Exception\LogicException,
8
    Visitor\AccessProperty
9
};
10
11 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...
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 18
    public function supports($object, string $property): bool
17
    {
18
        try {
19 18
            (new AccessProperty)($object, $property);
20
21 14
            return true;
22 6
        } catch (\Exception $e) {
23 6
            return false;
24
        }
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 12
    public function extract($object, string $property)
31
    {
32 12
        if (!$this->supports($object, $property)) {
33 2
            throw new LogicException;
34
        }
35
36 10
        $refl = (new AccessProperty)($object, $property);
37
38 10
        if (!$refl->isPublic()) {
39 6
            $refl->setAccessible(true);
40
        }
41
42 10
        $value = $refl->getValue($object);
43
44 10
        if (!$refl->isPublic()) {
45 6
            $refl->setAccessible(false);
46
        }
47
48 10
        return $value;
49
    }
50
}
51