Passed
Push — develop ( 185343...eb895f )
by Daniel
06:30
created

Image::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 ApiPlatform\Core\Annotation\ApiResource;
6
use Doctrine\ORM\Mapping as ORM;
7
use Silverback\ApiComponentBundle\Entity\Content\Component\AbstractComponent;
8
use Silverback\ApiComponentBundle\Entity\Content\FileInterface;
9
use Silverback\ApiComponentBundle\Entity\Content\FileTrait;
10
use Symfony\Component\Serializer\Annotation\Groups;
11
use Symfony\Component\Validator\Constraints as Assert;
12
use Symfony\Component\Validator\Mapping\ClassMetadata;
13
14
/**
15
 * @author Daniel West <[email protected]>
16
 * @ApiResource(iri="http://schema.org/ImageObject")
17
 * @ORM\Entity()
18
 */
19
class Image 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 1
    public static function loadValidatorMetadata(ClassMetadata $metadata)
34
    {
35 1
        $metadata->addPropertyConstraints(
36 1
            'filePath',
37 1
            [new Assert\NotBlank()] // , new Assert\Image()
38
        );
39 1
    }
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 Image
52
     */
53
    public function setCaption(?string $caption): self
54
    {
55
        $this->caption = $caption;
56
        return $this;
57
    }
58
}
59