Test Failed
Push — develop ( b13210...c32797 )
by Daniel
04:26
created

SimpleImage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCaption() 0 3 1
A setCaption() 0 4 1
A loadValidatorMetadata() 0 5 1
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Component\Image;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Silverback\ApiComponentBundle\Entity\Component\AbstractComponent;
7
use Silverback\ApiComponentBundle\Entity\Component\FileInterface;
8
use Silverback\ApiComponentBundle\Entity\Component\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
    public static function loadValidatorMetadata(ClassMetadata $metadata)
32
    {
33
        $metadata->addPropertyConstraints(
34
            'filePath',
35
            [new Assert\NotBlank()] // , new Assert\Image()
36
        );
37
    }
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