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

DefaultExtractionStrategies::get()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 12

Duplication

Lines 23
Ratio 100 %

Code Coverage

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