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

NamedMethodStrategy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 7 2
A inject() 0 8 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
9
/**
10
 * Looks for a method named exactly like the property
11
 *
12
 * Example:
13
 * <code>
14
 * private $foo;
15
 *
16
 * public function foo($foo);
17
 * </code>
18
 */
19
class NamedMethodStrategy implements InjectionStrategyInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 6
    public function supports($object, string $property, $value): bool
25
    {
26 6
        $refl = new \ReflectionObject($object);
27
28 6
        return $refl->hasMethod($property) &&
29 6
            $refl->getMethod($property)->getNumberOfParameters() > 0;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 3
    public function inject($object, string $property, $value)
36
    {
37 3
        if (!$this->supports($object, $property, $value)) {
38 1
            throw new LogicException;
39
        }
40
41 2
        $object->$property($value);
42 2
    }
43
}
44