Completed
Push — master ( 0be8e1...585ca2 )
by Daniel
59:26 queued 46:02
created

SimpleImage::loadValidatorMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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