Test Failed
Push — develop ( d382d0...28e0cd )
by Daniel
10:59
created

FeatureTextList::setColumns()   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 1
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 int
25
     */
26
    protected $columns = 3;
27
28
    /**
29
     * @param ClassMetadata $metadata
30
     */
31
    public static function loadValidatorMetadata(ClassMetadata $metadata): void
32
    {
33
        $metadata->addPropertyConstraint(
34
            'columns',
35
            new Assert\Range(
36
                [
37
                    'min' => 1,
38 1
                    'minMessage' => 'The FeatureColumns component must have at least 1 column'
39
                ]
40 1
            )
41 1
        );
42 1
    }
43
44 1
    /**
45
     * @return int
46
     */
47
    public function getColumns(): int
48
    {
49 1
        return $this->columns;
50
    }
51
52
    /**
53
     * @param int $columns
54
     */
55
    public function setColumns(int $columns): void
56
    {
57
        $this->columns = $columns;
58
    }
59
}
60