Passed
Push — develop ( 0112d6...38c008 )
by Daniel
05:14
created

Hero::getSubtitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Content\Component\Hero;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Silverback\ApiComponentBundle\Entity\Content\Component\AbstractComponent;
7
use Silverback\ApiComponentBundle\Entity\Content\Component\Navigation\Tabs\Tabs;
8
use Silverback\ApiComponentBundle\Entity\Content\ComponentGroup;
9
use Silverback\ApiComponentBundle\Entity\Content\FileInterface;
10
use Silverback\ApiComponentBundle\Entity\Content\FileTrait;
11
use Symfony\Component\Serializer\Annotation\Groups;
12
use Symfony\Component\Validator\Constraints as Assert;
13
use Symfony\Component\Validator\Mapping\ClassMetadata;
14
15
/**
16
 * Class Hero
17
 * @package Silverback\ApiComponentBundle\Entity\Content\Component\Hero
18
 * @author Daniel West <[email protected]>
19
 * @ORM\Entity()
20
 */
21
class Hero extends AbstractComponent implements FileInterface
22
{
23
    use FileTrait;
24
25
    /**
26
     * @ORM\Column(type="string", nullable=false)
27
     * @Groups({"content", "component"})
28
     * @var null|string
29
     */
30
    private $title;
31
32
    /**
33
     * @ORM\Column(type="string")
34
     * @Groups({"content", "component"})
35
     * @var null|string
36
     */
37
    private $subtitle;
38
39 3
    public function __construct()
40
    {
41 3
        parent::__construct();
42 3
        $this->addValidComponent(Tabs::class);
43 3
        $this->addComponentGroup(new ComponentGroup());
44 3
    }
45
46 3
    public static function loadValidatorMetadata(ClassMetadata $metadata)
47
    {
48 3
        $metadata->addPropertyConstraint(
49 3
            'title',
50 3
            new Assert\NotNull()
51
        );
52
//        $metadata->addPropertyConstraint(
53
//            'filePath',
54
//            new Assert\Image()
55
//        );
56 3
    }
57
58
    /**
59
     * @return null|string
60
     */
61 1
    public function getTitle(): ?string
62
    {
63 1
        return $this->title;
64
    }
65
66
    /**
67
     * @param null|string $title
68
     */
69 2
    public function setTitle(?string $title): void
70
    {
71 2
        $this->title = $title;
72 2
    }
73
74
    /**
75
     * @return null|string
76
     */
77 1
    public function getSubtitle(): ?string
78
    {
79 1
        return $this->subtitle;
80
    }
81
82
    /**
83
     * @param null|string $subtitle
84
     */
85 2
    public function setSubtitle(?string $subtitle): void
86
    {
87 2
        $this->subtitle = $subtitle;
88 2
    }
89
90
    public function __toString()
91
    {
92
        return 'Hero: ' . $this->getTitle();
93
    }
94
}
95