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 ( de2245...dcc1f2 )
by Baptiste
05:00 queued 02:53
created

GetterStrategy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 39
ccs 15
cts 15
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A supports() 0 10 2
A extract() 0 12 2
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
use Innmind\Immutable\StringPrimitive;
9
10
class GetterStrategy implements ExtractionStrategyInterface
11
{
12
    private $getter;
13
14 5
    public function __construct()
15
    {
16 5
        $this->getter = new StringPrimitive('get%s');
17 5
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 5
    public function supports($object, string $property): bool
23
    {
24 5
        $refl = new \ReflectionObject($object);
25 5
        $getter = (string) $this->getter->sprintf(
26 5
            (string) (new StringPrimitive($property))->camelize()
0 ignored issues
show
Bug introduced by
The method camelize() does not seem to exist on object<Innmind\Immutable\StringPrimitive>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        );
28
29 5
        return $refl->hasMethod($getter) &&
30 5
            $refl->getMethod($getter)->getNumberOfRequiredParameters() === 0;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 3
    public function extract($object, string $property)
37
    {
38 3
        if (!$this->supports($object, $property)) {
39 1
            throw new LogicException;
40
        }
41
42 2
        $getter = (string) $this->getter->sprintf(
43 2
            (string) (new StringPrimitive($property))->camelize()
0 ignored issues
show
Bug introduced by
The method camelize() does not seem to exist on object<Innmind\Immutable\StringPrimitive>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        );
45
46 2
        return $object->$getter();
47
    }
48
}
49