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

FeatureTextList::setColumns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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