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

AbstractFeatureItem   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 76.47%

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 13
cts 17
cp 0.7647
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getLink() 0 3 1
A getLabel() 0 3 1
A loadValidatorMetadata() 0 9 1
A setLabel() 0 3 1
A setLink() 0 3 1
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