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

AbstractPage::getDefaultRouteName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 1
cts 1
cp 1
cc 1
nc 1
nop 0
crap 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