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.

ReflectionStrategy::extract()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

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