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

FeatureTextList   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

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

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
 * 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