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

SimpleImage::setCaption()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Content\Component\Image;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Silverback\ApiComponentBundle\Entity\Content\Component\AbstractComponent;
7
use Silverback\ApiComponentBundle\Entity\Content\FileInterface;
8
use Silverback\ApiComponentBundle\Entity\Content\FileTrait;
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
 * @author Daniel West <[email protected]>
15
 * @ORM\Entity()
16
 */
17
class SimpleImage extends AbstractComponent implements FileInterface
18
{
19
    use FileTrait;
20
21
    /**
22
     * @ORM\Column(nullable=true)
23
     * @Groups({"component", "content"})
24
     * @var null|string
25
     */
26
    protected $caption;
27
28
    /**
29
     * @param ClassMetadata $metadata
30
     */
31 1
    public static function loadValidatorMetadata(ClassMetadata $metadata)
32
    {
33 1
        $metadata->addPropertyConstraints(
34 1
            'filePath',
35 1
            [new Assert\NotBlank()] // , new Assert\Image()
36
        );
37 1
    }
38
39
    /**
40
     * @return null|string
41
     */
42
    public function getCaption(): ?string
43
    {
44
        return $this->caption;
45
    }
46
47
    /**
48
     * @param null|string $caption
49
     * @return SimpleImage
50
     */
51
    public function setCaption(?string $caption): self
52
    {
53
        $this->caption = $caption;
54
        return $this;
55
    }
56
}
57