Completed
Push — master ( 8b8c0c...ed931d )
by Pavel
02:40
created

StaticPageRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A getByTargetDestination() 0 8 2
1
<?php
2
3
namespace Bankiru\Seo\Integration\Local;
4
5
use Bankiru\Seo\DestinationInterface;
6
use Bankiru\Seo\Exception\PageException;
7
use Bankiru\Seo\Page\SeoPageInterface;
8
use Bankiru\Seo\PageRepositoryInterface;
9
use Bankiru\Seo\TargetDefinitionInterface;
10
11
final class StaticPageRepository implements PageRepositoryInterface
12
{
13
    /** @var SeoPageInterface[] */
14
    private $pages = [];
15
16 9
    public function add(TargetDefinitionInterface $target, SeoPageInterface $page)
17
    {
18 9
        $this->pages[$target->getRoute()] = $page;
19 9
    }
20
21
    /** {@inheritdoc} */
22 4
    public function getByTargetDestination(TargetDefinitionInterface $target, DestinationInterface $destination = null)
23
    {
24 4
        if (!array_key_exists($target->getRoute(), $this->pages)) {
25 1
            throw PageException::notFound($target);
26
        }
27
28 3
        return $this->pages[$target->getRoute()];
29
    }
30
}
31