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 — develop ( 6d95b6...ad64b7 )
by Baptiste
02:31
created

SetterStrategy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 34
ccs 13
cts 13
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A supports() 0 8 1
A inject() 0 9 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Reflection\InjectionStrategy;
5
6
use Innmind\Reflection\InjectionStrategyInterface;
7
use Innmind\Reflection\Exception\LogicException;
8
use Innmind\Immutable\StringPrimitive;
9
10
class SetterStrategy implements InjectionStrategyInterface
11
{
12
    private $setter;
13
14 8
    public function __construct()
15
    {
16 8
        $this->setter = new StringPrimitive('set%s');
17 8
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 6
    public function supports($object, string $property, $value): bool
23
    {
24 6
        $refl = new \ReflectionObject($object);
25
26 6
        return $refl->hasMethod(
27 6
            (string) $this->setter->sprintf(ucfirst($property))
28
        );
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 3
    public function inject($object, string $property, $value)
35
    {
36 3
        if (!$this->supports($object, $property, $value)) {
37 1
            throw new LogicException;
38
        }
39
40 2
        $setter = (string) $this->setter->sprintf(ucfirst($property));
41 2
        $object->$setter($value);
42 2
    }
43
}
44