Passed
Push — develop ( 53a66f...07e04a )
by Daniel
05:35
created

AbstractFeatureItem::loadValidatorMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
ccs 7
cts 7
cp 1
crap 1
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Component\Feature;
4
5
use Silverback\ApiComponentBundle\Entity\Component\AbstractComponent;
6
use Symfony\Component\Serializer\Annotation\Groups;
7
use Symfony\Component\Validator\Constraints as Assert;
8
use Symfony\Component\Validator\Mapping\ClassMetadata;
9
10
/**
11
 * Class AbstractFeatureItem
12
 * @package Silverback\ApiComponentBundle\Entity\Component\Feature
13
 */
14
abstract class AbstractFeatureItem extends AbstractComponent implements FeatureItemInterface
15
{
16
    /**
17
     * @Groups({"component", "content"})
18
     * @var string
19
     */
20
    private $label;
21
22
    /**
23
     * @Groups({"component", "content"})
24
     * @var string|null
25
     */
26
    protected $link;
27
28 2
    public static function loadValidatorMetadata(ClassMetadata $metadata)
29
    {
30 2
        $metadata->addPropertyConstraint(
31 2
            'label',
32 2
            new Assert\NotBlank()
33
        );
34 2
        $metadata->addPropertyConstraint(
35 2
            'link',
36 2
            new Assert\Url()
37
        );
38 2
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getLabel(): string
44
    {
45
        return $this->label;
46
    }
47
48
    /**
49
     * @param string $label
50
     */
51 3
    public function setLabel(string $label): void
52
    {
53 3
        $this->label = $label;
54 3
    }
55
56
    /**
57
     * @return null|string
58
     */
59
    public function getLink(): ?string
60
    {
61
        return $this->link;
62
    }
63
64
    /**
65
     * @param null|string $link
66
     */
67 3
    public function setLink(?string $link): void
68
    {
69 3
        $this->link = $link;
70 3
    }
71
}
72