Completed
Push — master ( 51af85...b489fc )
by Pavel
06:35
created

StaticTargetRepository::findByRoute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Bankiru\Seo\Integration\Local;
4
5
use Bankiru\Seo\TargetDefinitionInterface;
6
use Bankiru\Seo\TargetRepositoryInterface;
7
8
final class StaticTargetRepository implements TargetRepositoryInterface
9
{
10
    /**
11
     * @var TargetDefinitionInterface[][]
12
     */
13
    private $targets = [];
14
15
    public function add(TargetDefinitionInterface $target)
16
    {
17
        $this->targets[$target->getRoute()][] = $target;
18
    }
19
20
    /** {@inheritdoc} */
21
    public function findByRoute($route)
22
    {
23
        if (!array_key_exists($route, $this->targets)) {
24
            return [];
25
        }
26
27
        return $this->targets[$route];
28
    }
29
}
30