Completed
Push — develop ( e326d5...b2cbdf )
by Daniel
09:21
created

FeatureTextList::getColumns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 1
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\Feature\TextList;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Silverback\ApiComponentBundle\Entity\Component\Feature\AbstractFeature;
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
 * Class FeatureTextList
15
 * @package Silverback\ApiComponentBundle\Entity\Component\FeatureList
16
 * @author Daniel West <[email protected]>
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 1
     * @param ClassMetadata $metadata
37
     */
38 1
    public static function loadValidatorMetadata(ClassMetadata $metadata): void
39 1
    {
40 1
        $metadata->addPropertyConstraint(
41
            'columns',
42 1
            new Assert\Range(
43
                [
44
                    'min' => 1,
45
                    'minMessage' => 'The FeatureColumns component must have at least 1 column'
46
                ]
47 1
            )
48
        );
49
    }
50
51
    /**
52
     * @return null|string
53
     */
54
    public function getTitle(): ?string
55
    {
56
        return $this->title;
57
    }
58
59
    /**
60
     * @param null|string $title
61
     */
62
    public function setTitle(?string $title): void
63
    {
64
        $this->title = $title;
65
    }
66
67
    /**
68
     * @return int
69
     */
70
    public function getColumns(): int
71
    {
72
        return $this->columns;
73
    }
74
75
    /**
76
     * @param int $columns
77
     */
78
    public function setColumns(int $columns): void
79
    {
80
        $this->columns = $columns;
81
    }
82
}
83