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

FeatureTextList   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 39
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loadValidatorMetadata() 0 8 1
A getColumns() 0 3 1
A setColumns() 0 3 1
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