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

PageTrait   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
eloc 15
dl 0
loc 66
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getLayout() 0 3 1
A getDefaultRoute() 0 3 1
A getMetaDescription() 0 3 2
A setMetaDescription() 0 4 1
A getDefaultRouteName() 0 3 1
A setTitle() 0 4 1
A getTitle() 0 3 2
A setLayout() 0 4 1
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Content\Page;
4
5
use ApiPlatform\Core\Annotation\ApiProperty;
6
use Doctrine\ORM\Mapping as ORM;
7
use Silverback\ApiComponentBundle\Entity\Layout\Layout;
8
use Symfony\Component\Serializer\Annotation\Groups;
9
10
trait PageTrait
11
{
12
    /**
13
     * @ORM\Column()
14
     * @Groups({"default"})
15
     * @var string
16
     */
17
    protected $title = 'Unnamed Page';
18
19
    /**
20
     * @ORM\Column(nullable=true)
21
     * @Groups({"content", "route"})
22
     * @var string
23
     */
24
    protected $metaDescription;
25
26
    /**
27
     * @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Layout\Layout")
28
     * @ORM\JoinColumn(onDelete="SET NULL")
29
     * @ApiProperty()
30
     * @Groups({"content","route"})
31
     * @var Layout|null
32
     */
33
    protected $layout;
34
35
    public function getTitle(): string
36
    {
37
        return $this->title ?: 'unnamed';
38
    }
39
40
    public function setTitle(string $title): self
41
    {
42
        $this->title = $title;
43
        return $this;
44
    }
45
46
    public function getMetaDescription(): string
47
    {
48
        return $this->metaDescription ?: '';
49
    }
50
51
    public function setMetaDescription(string $metaDescription): self
52
    {
53
        $this->metaDescription = $metaDescription;
54
        return $this;
55
    }
56
57
    public function getLayout(): ?Layout
58
    {
59
        return $this->layout;
60
    }
61
62
    public function setLayout(?Layout $layout): self
63
    {
64
        $this->layout = $layout;
65
        return $this;
66
    }
67
68
    public function getDefaultRoute(): string
69
    {
70
        return $this->getTitle();
71
    }
72
73
    public function getDefaultRouteName(): string
74
    {
75
        return $this->getTitle();
76
    }
77
}
78