Completed
Push — master ( 382b22...57bef4 )
by Pavel
02:35
created

StaticTargetRepository::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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 4
    public function add(TargetDefinitionInterface $target)
16
    {
17 4
        $this->targets[$target->getRoute()][] = $target;
18 4
    }
19
20
    /** {@inheritdoc} */
21 3
    public function findByRoute($route)
22
    {
23 3
        if (!array_key_exists($route, $this->targets)) {
24 1
            return [];
25
        }
26
27 2
        return $this->targets[$route];
28
    }
29
}
30