Test Failed
Push — develop ( 05150f...e72854 )
by Daniel
04:23
created

ArticlePage   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
wmc 7
eloc 20
dl 0
loc 74
ccs 8
cts 18
cp 0.4444
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getContent() 0 3 1
A setSubtitle() 0 4 1
A setContent() 0 4 1
A setImageCaption() 0 4 1
A getImageCaption() 0 3 1
A getSubtitle() 0 3 1
A loadValidatorMetadata() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Silverback\ApiComponentBundle\Entity\Content\Page\Dynamic;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Silverback\ApiComponentBundle\Entity\Component\FileInterface;
9
use Silverback\ApiComponentBundle\Entity\Component\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
 *
16
 * @author Daniel West <[email protected]>
17
 * @ORM\Entity()
18
 * @ORM\AttributeOverrides({
19
 *      @ORM\AttributeOverride(
20
 *          name="filePath",
21
 *          column=@ORM\Column(
22
 *              nullable=true
23
 *          )
24
 *      )
25
 * })
26
 */
27
class ArticlePage extends AbstractDynamicPage implements FileInterface
28
{
29
    use FileTrait;
30
31
    /**
32
     * @ORM\Column(type="string")
33
     * @Groups({"content", "component", "route"})
34
     * @var null|string
35
     */
36
    private $subtitle;
37
38
    /**
39
     * @ORM\Column(type="text")
40
     * @Groups({"content", "component", "route"})
41
     * @var string
42
     */
43
    private $content = '';
44
45 1
    /**
46
     * @ORM\Column(type="string")
47
     * @Groups({"content", "component", "route"})
48
     * @var null|string
49
     */
50
    private $imageCaption;
51
52 1
    public static function loadValidatorMetadata(ClassMetadata $metadata): void
53 1
    {
54 1
//        $metadata->addPropertyConstraint(
55
//            'filePath',
56
//            new Assert\Image()
57 1
//        );
58 1
59 1
        $metadata->addPropertyConstraint(
60
            'title',
61 1
            new Assert\NotNull()
62
        );
63
64
        $metadata->addPropertyConstraint(
65
            'content',
66
            new Assert\NotNull()
67
        );
68
    }
69
70
    public function getSubtitle(): ?string
71
    {
72
        return $this->subtitle;
73
    }
74
75
    public function setSubtitle(?string $subtitle): self
76
    {
77
        $this->subtitle = $subtitle;
78
        return $this;
79
    }
80
81
    public function getContent(): string
82
    {
83
        return $this->content;
84
    }
85
86
    public function setContent(string $content): self
87
    {
88
        $this->content = $content;
89
        return $this;
90
    }
91
92
    public function setImageCaption(string $imageCaption): self
93
    {
94
        $this->imageCaption = $imageCaption;
95
        return $this;
96
    }
97
98
    public function getImageCaption(): ?string
99
    {
100
        return $this->imageCaption;
101
    }
102
}
103