Passed
Push — master ( 77414c...fb8c39 )
by Daniel
12:16
created

FeatureTextList::loadValidatorMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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
 * @ORM\Entity()
15
 */
16
class FeatureTextList extends AbstractFeature
17
{
18
    /**
19
     * @ORM\Column(type="integer")
20
     * @Groups({"component", "content"})
21
     * @var int
22
     */
23
    protected $columns = 3;
24
25
    /**
26
     * @param ClassMetadata $metadata
27
     */
28
    public static function loadValidatorMetadata(ClassMetadata $metadata): void
29
    {
30
        $metadata->addPropertyConstraint(
31
            'columns',
32
            new Assert\Range(
33
                [
34
                    'min' => 1,
35
                    'minMessage' => 'The FeatureColumns component must have at least 1 column'
36
                ]
37
            )
38 1
        );
39
    }
40 1
41 1
    /**
42 1
     * @return int
43
     */
44 1
    public function getColumns(): int
45
    {
46
        return $this->columns;
47
    }
48
49 1
    /**
50
     * @param int $columns
51
     */
52
    public function setColumns(int $columns): void
53
    {
54
        $this->columns = $columns;
55
    }
56
}
57