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 ( 32827b...8dd213 )
by Baptiste
02:19
created

IsserStrategy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A supports() 10 10 2
A extract() 12 12 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Reflection\ExtractionStrategy;
5
6
use Innmind\Reflection\Exception\LogicException;
7
use Innmind\Immutable\StringPrimitive;
8
9 View Code Duplication
class IsserStrategy 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
    private $isser;
12
13 8
    public function __construct()
14
    {
15 8
        $this->isser = new StringPrimitive('is%s');
16 8
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 6
    public function supports($object, string $property): bool
22
    {
23 6
        $refl = new \ReflectionObject($object);
24 6
        $isser = (string) $this->isser->sprintf(
25 6
            (string) (new StringPrimitive($property))->camelize()
26
        );
27
28 6
        return $refl->hasMethod($isser) &&
29 6
            $refl->getMethod($isser)->getNumberOfRequiredParameters() === 0;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 2
    public function extract($object, string $property)
36
    {
37 2
        if (!$this->supports($object, $property)) {
38 1
            throw new LogicException;
39
        }
40
41 1
        $isser = (string) $this->isser->sprintf(
42 1
            (string) (new StringPrimitive($property))->camelize()
43
        );
44
45 1
        return $object->$isser();
46
    }
47
}
48