Test Failed
Push — develop ( 92c10d...ff12cf )
by Daniel
05:05
created

AbstractPage   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 11
dl 0
loc 48
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setParent() 0 4 1
A getParent() 0 3 1
A getDefaultRouteName() 0 3 1
A getParentRoute() 0 3 2
A getDefaultRoute() 0 3 1
A isDynamic() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Silverback\ApiComponentBundle\Entity\Content\Page;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Silverback\ApiComponentBundle\Entity\Content\AbstractContent;
9
use Silverback\ApiComponentBundle\Entity\Route\Route;
10
use Symfony\Component\Serializer\Annotation\Groups;
11
12
/**
13
 * @ORM\Entity()
14
 */
15
abstract class AbstractPage extends AbstractContent implements PageInterface
16
{
17
    use PageTrait;
18
19
    /**
20
     * @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Content\Page\AbstractPage")
21
     * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
22
     * @Groups({"route"})
23
     * @var null|StaticPage
24
     */
25
    protected $parent;
26
27
    /**
28
     * @ORM\Column(type="boolean")
29
     * @Groups({"content", "route", "component"})
30
     * @var boolean
31
     */
32
    protected $dynamic = false;
33
34
    public function getParent(): ?StaticPage
35
    {
36
        return $this->parent;
37
    }
38
39
    public function setParent(?StaticPage $parent): self
40
    {
41
        $this->parent = $parent;
42
        return $this;
43
    }
44
45
    public function isDynamic(): bool
46
    {
47
        return $this->dynamic;
48
    }
49
50
    public function getDefaultRoute(): string
51
    {
52
        return $this->getTitle();
53
    }
54
55
    public function getDefaultRouteName(): string
56
    {
57 1
        return $this->getTitle();
58
    }
59 1
60 1
    public function getParentRoute(): ?Route
61 1
    {
62
        return $this->getParent() ? $this->getParent()->getRoutes()->first() : null;
63
    }
64
}
65