Passed
Push — develop ( 1103e1...06ad9c )
by Daniel
05:06
created

FeatureTextList::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Content\Component\Feature\TextList;
4
5
use ApiPlatform\Core\Annotation\ApiResource;
6
use Doctrine\ORM\Mapping as ORM;
7
use Silverback\ApiComponentBundle\Entity\Content\Component\Feature\AbstractFeature;
8
use Symfony\Component\Serializer\Annotation\Groups;
9
use Symfony\Component\Validator\Constraints as Assert;
10
use Symfony\Component\Validator\Mapping\ClassMetadata;
11
12
/**
13
 * Class FeatureTextList
14
 * @package Silverback\ApiComponentBundle\Entity\Content\Component\FeatureList
15
 * @author Daniel West <[email protected]>
16
 * @ApiResource()
17
 * @ORM\Entity()
18
 */
19
class FeatureTextList extends AbstractFeature
20
{
21
    /**
22
     * @ORM\Column()
23
     * @Groups({"component", "content"})
24
     * @var null|string
25
     */
26
    protected $title;
27
28
    /**
29
     * @ORM\Column()
30
     * @Groups({"component", "content"})
31
     * @var int
32
     */
33
    protected $columns = 3;
34
35
    /**
36
     * @param ClassMetadata $metadata
37
     */
38 6
    public static function loadValidatorMetadata(ClassMetadata $metadata): void
39
    {
40 6
        $metadata->addPropertyConstraint(
41 6
            'columns',
42 6
            new Assert\Range(
43
                [
44 6
                    'min' => 1,
45
                    'minMessage' => 'The FeatureColumns component must have at least 1 column'
46
                ]
47
            )
48
        );
49 6
    }
50
51
    /**
52
     * @return null|string
53
     */
54 1
    public function getTitle(): ?string
55
    {
56 1
        return $this->title;
57
    }
58
59
    /**
60
     * @param null|string $title
61
     */
62 2
    public function setTitle(?string $title): void
63
    {
64 2
        $this->title = $title;
65 2
    }
66
67
    /**
68
     * @return int
69
     */
70 1
    public function getColumns(): int
71
    {
72 1
        return $this->columns;
73
    }
74
75
    /**
76
     * @param int $columns
77
     */
78 2
    public function setColumns(int $columns): void
79
    {
80 2
        $this->columns = $columns;
81 2
    }
82
}
83