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 ( 5e8f41...c39771 )
by Baptiste
06:33
created

DefaultInjectionStrategies::all()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 2
Metric Value
dl 15
loc 15
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Innmind\Reflection\InjectionStrategy;
4
5
use Innmind\Immutable\TypedCollection;
6
use Innmind\Immutable\TypedCollectionInterface;
7
use Innmind\Reflection\Cache\StrategyCachingCapabilities;
8
use Innmind\Reflection\Exception\LogicException;
9
10
/**
11
 * DefaultInjectionStrategies
12
 *
13
 * @author Hugues Maignol <[email protected]>
14
 */
15 View Code Duplication
final class DefaultInjectionStrategies implements InjectionStrategies
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...
16
{
17
    use StrategyCachingCapabilities;
18
19
    private $strategies;
20
21 8
    public function all(): TypedCollectionInterface
22
    {
23 8
        if ($this->strategies == null) {
24 8
            return $this->strategies = new TypedCollection(
25 8
                InjectionStrategyInterface::class,
26
                [
27 8
                    new SetterStrategy,
28 8
                    new NamedMethodStrategy,
29 8
                    new ReflectionStrategy,
30
                ]
31
            );
32
        }
33
34 2
        return $this->strategies;
35
    }
36
37 5
    public function get($object, string $key, $value): InjectionStrategyInterface
38
    {
39 5
        $strategy = $this->getCachedStrategy(get_class($object), $key);
40 5
        if (null !== $strategy) {
41
            return $strategy;
42
        }
43
44 5
        foreach ($this->all() as $strategy) {
45 5
            if ($strategy->supports($object, $key, $value)) {
46
47 3
                $this->setCachedStrategy(get_class($object), $key, $strategy);
48
49 5
                return $strategy;
50
            }
51
        }
52
53 2
        throw new LogicException(
54
            sprintf(
55 2
                'Property "%s" cannot be injected',
56
                $key
57
            )
58
        );
59
    }
60
}
61