Test Failed
Branch develop (ac2838)
by Daniel
09:09
created

Hero   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 83
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getTabs() 0 3 1
A setTabs() 0 3 1
A loadValidatorMetadata() 0 5 1
A __toString() 0 3 1
A setTitle() 0 3 1
A getSubtitle() 0 3 1
A setSubtitle() 0 3 1
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Component\Hero;
4
5
use ApiPlatform\Core\Annotation\ApiResource;
6
use Doctrine\ORM\Mapping as ORM;
7
use Silverback\ApiComponentBundle\Entity\Component\AbstractComponent;
8
use Silverback\ApiComponentBundle\Entity\Component\Navigation\Tabs\Tabs;
9
use Symfony\Component\Serializer\Annotation\Groups;
10
use Symfony\Component\Validator\Constraints as Assert;
11
use Symfony\Component\Validator\Mapping\ClassMetadata;
12
13
/**
14
 * Class Hero
15
 * @package Silverback\ApiComponentBundle\Entity\Component\Hero
16
 * @author Daniel West <[email protected]>
17
 * @ApiResource(shortName="component/hero")
18
 * @ORM\Entity()
19
 */
20
class Hero extends AbstractComponent
21
{
22
    /**
23
     * @ORM\Column(type="string", nullable=false)
24
     * @Groups({"content", "component"})
25
     * @var null|string
26
     */
27
    private $title;
28
29
    /**
30
     * @ORM\Column(type="string")
31
     * @Groups({"content", "component"})
32
     * @var null|string
33
     */
34
    private $subtitle;
35
36
    /**
37
     * @ORM\ManyToOne(targetEntity="\Silverback\ApiComponentBundle\Entity\Component\Navigation\Tabs\Tabs")
38
     * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
39
     * @Groups({"content", "component"})
40
     * @var null|Tabs
41
     */
42
    private $tabs;
43
44
    public static function loadValidatorMetadata(ClassMetadata $metadata)
45
    {
46
        $metadata->addPropertyConstraint(
47
            'title',
48
            new Assert\NotNull()
49
        );
50
    }
51
52
    /**
53
     * @return null|string
54
     */
55
    public function getTitle(): ?string
56
    {
57
        return $this->title;
58
    }
59
60
    /**
61
     * @param null|string $title
62
     */
63
    public function setTitle(?string $title): void
64
    {
65
        $this->title = $title;
66
    }
67
68
    /**
69
     * @return null|string
70
     */
71
    public function getSubtitle(): ?string
72
    {
73
        return $this->subtitle;
74
    }
75
76
    /**
77
     * @param null|string $subtitle
78
     */
79
    public function setSubtitle(?string $subtitle): void
80
    {
81
        $this->subtitle = $subtitle;
82
    }
83
84
    /**
85
     * @return Tabs|null
86
     */
87
    public function getTabs(): ?Tabs
88
    {
89
        return $this->tabs;
90
    }
91
92
    /**
93
     * @param Tabs|null $tabs
94
     */
95
    public function setTabs(?Tabs $tabs): void
96
    {
97
        $this->tabs = $tabs;
98
    }
99
100
    public function __toString()
101
    {
102
        return 'Hero: ' . $this->getTitle();
103
    }
104
}
105