MasterSeoRequest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 82.35%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 50
ccs 14
cts 17
cp 0.8235
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDestination() 0 8 2
A setDestination() 0 4 1
A getPage() 0 8 2
A getRenderedPage() 0 4 1
1
<?php
2
3
namespace Bankiru\Seo\Listener;
4
5
use Bankiru\Seo\DestinationInterface;
6
use Bankiru\Seo\DestinationMatcherInterface;
7
use Bankiru\Seo\Page\SeoPageInterface;
8
9
class MasterSeoRequest implements SeoRequestInterface
10
{
11
    /** @var  DestinationInterface */
12
    private $destination;
13
    /** @var  SeoPageInterface */
14
    private $page;
15
    /** @var  DestinationMatcherInterface */
16
    private $matcher;
17
18
    /**
19
     * MasterSeoRequest constructor.
20
     *
21
     * @param DestinationMatcherInterface $matcher
22
     */
23 3
    public function __construct(DestinationMatcherInterface $matcher)
24
    {
25 3
        $this->matcher = $matcher;
26 3
    }
27
28
    /** {@inheritdoc} */
29 2
    public function getDestination()
30
    {
31 2
        if (null === $this->destination) {
32
            throw new \LogicException('Destination is not set');
33
        }
34
35 2
        return $this->destination;
36
    }
37
38
    /** {@inheritdoc} */
39 2
    public function setDestination(DestinationInterface $destination)
40
    {
41 2
        $this->destination = $destination;
42 2
    }
43
44
    /** {@inheritdoc} */
45 2
    public function getPage()
46
    {
47 2
        if (null === $this->page) {
48 2
            $this->page = $this->matcher->match($this->getDestination());
49 1
        }
50
51 1
        return $this->page;
52
    }
53
54
    public function getRenderedPage()
55
    {
56
        return $this->getPage();
57
    }
58
}
59