Passed
Branch develop (2eaa9a)
by Daniel
05:29
created

GalleryItem::getCaption()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Component\Gallery;
4
5
use ApiPlatform\Core\Annotation\ApiResource;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Silverback\ApiComponentBundle\Entity\Component\AbstractComponent;
9
use Silverback\ApiComponentBundle\Entity\Component\FileInterface;
10
use Silverback\ApiComponentBundle\Entity\Component\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 GalleryItem
17
 * @package Silverback\ApiComponentBundle\Entity\Component\Gallery
18
 * @author Daniel West <[email protected]>
19
 * @ApiResource(shortName="component/gallery_item")
20
 * @ORM\Entity()
21
 */
22
class GalleryItem extends AbstractComponent implements FileInterface
23
{
24
    use FileTrait;
25
26
    /**
27
     * @ORM\Column()
28
     * @Groups({"component", "content"})
29
     * @var null|string
30
     */
31
    protected $title;
32
33
    /**
34
     * @ORM\Column()
35
     * @Groups({"component", "content"})
36
     * @var null|string
37
     */
38
    protected $caption;
39
40
    /**
41
     * @param ClassMetadata $metadata
42
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
43
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
44
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
45
     */
46 1
    public static function loadValidatorMetadata(ClassMetadata $metadata)
47
    {
48 1
        $metadata->addPropertyConstraint(
49 1
            'filePath',
50 1
            new Assert\NotBlank()
51
        );
52 1
        $metadata->addPropertyConstraint(
53 1
            'title',
54 1
            new Assert\NotBlank()
55
        );
56 1
    }
57
58
    /**
59
     * Gallery constructor.
60
     */
61 1
    public function __construct()
62
    {
63 1
        parent::__construct();
64 1
    }
65
66
    /**
67
     * @return null|string
68
     */
69
    public function getTitle(): ?string
70
    {
71
        return $this->title;
72
    }
73
74
    /**
75
     * @param null|string $title
76
     * @return GalleryItem
77
     */
78
    public function setTitle(?string $title): self
79
    {
80
        $this->title = $title;
81
        return $this;
82
    }
83
84
    /**
85
     * @return null|string
86
     */
87
    public function getCaption(): ?string
88
    {
89
        return $this->caption;
90
    }
91
92
    /**
93
     * @param null|string $caption
94
     * @return GalleryItem
95
     */
96
    public function setCaption(?string $caption): self
97
    {
98
        $this->caption = $caption;
99
        return $this;
100
    }
101
}
102