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.

IsserStrategy::supports()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 3
nop 2
dl 0
loc 19
ccs 10
cts 10
cp 1
crap 3
rs 9.9
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
};
10
use Innmind\Immutable\Str;
11
12
final class IsserStrategy implements ExtractionStrategy
13
{
14
    private Str $isser;
15
16 6
    public function __construct()
17
    {
18 6
        $this->isser = Str::of('is%s');
19 6
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 6
    public function supports(object $object, string $property): bool
25
    {
26 6
        $refl = new \ReflectionObject($object);
27 6
        $isser = $this
28 6
            ->isser
29
            ->sprintf(Str::of($property)->camelize()->ucfirst()->toString())
30
            ->toString();
31 6
32 4
        if (!$refl->hasMethod($isser)) {
33
            return false;
34
        }
35 3
36
        $isser = $refl->getMethod($isser);
37 3
38 1
        if (!$isser->isPublic()) {
39
            return false;
40
        }
41 3
42
        return $isser->getNumberOfRequiredParameters() === 0;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47 3
     */
48
    public function extract(object $object, string $property)
49 3
    {
50 1
        if (!$this->supports($object, $property)) {
51
            throw new LogicException;
52
        }
53 2
54 2
        $isser = $this
55
            ->isser
56
            ->sprintf(Str::of($property)->camelize()->ucfirst()->toString())
57 2
            ->toString();
58
59
        /** @psalm-suppress MixedMethodCall */
60
        return $object->$isser();
61
    }
62
}
63