Completed
Push — master ( 9feb73...477747 )
by Joachim
25:18 queued 10:20
created

Tag::getTagValues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Loevgaard\DandomainFoundation\Entity;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use Doctrine\ORM\Mapping as ORM;
6
use Loevgaard\DandomainFoundation\Entity\Generated\TagInterface;
7
use Loevgaard\DandomainFoundation\Entity\Generated\TagTrait;
8
9
/**
10
 * @ORM\Entity()
11
 * @ORM\Table(name="loevgaard_dandomain_tags")
12
 */
13
class Tag extends AbstractEntity implements TagInterface
14
{
15
    use TagTrait;
16
17
    /**
18
     * @var int
19
     *
20
     * @ORM\Id
21
     * @ORM\GeneratedValue
22
     * @ORM\Column(type="integer")
23
     **/
24
    protected $id;
25
26
    /**
27
     * @var int
28
     *
29
     * @ORM\Column(type="integer", unique=true)
30
     **/
31
    protected $externalId;
32
33
    /**
34
     * @var string|null
35
     *
36
     * @ORM\Column(type="string", nullable=true)
37
     **/
38
    protected $selectorType;
39
40
    /**
41
     * @var int|null
42
     *
43
     * @ORM\Column(type="integer", nullable=true)
44
     **/
45
    protected $sortOrder;
46
47
    /**
48
     * @var TagValue[]|ArrayCollection
49
     * @todo create doctrine mapping
50
     */
51
    protected $tagValues;
52
53
    public function __construct()
54
    {
55
        $this->tagValues = new ArrayCollection();
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61
    public function addTagValue(TagValue $tagValue) {
62
        if(!$this->tagValues->contains($tagValue)) {
63
            $this->tagValues->add($tagValue);
64
            $tagValue->setTag($this);
65
        }
66
        return $this;
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72
    public function clearTagValues() {
73
        foreach($this->tagValues as $tagValue) {
74
            $this->tagValues->removeElement($tagValue);
75
        }
76
77
        return $this;
78
    }
79
80
    /**
81
     * @return int
82
     */
83
    public function getId(): int
84
    {
85
        return (int)$this->id;
86
    }
87
88
    /**
89
     * @param int $id
90
     * @return Tag
91
     */
92
    public function setId(int $id)
93
    {
94
        $this->id = $id;
95
        return $this;
96
    }
97
98
    /**
99
     * @return int
100
     */
101
    public function getExternalId(): int
102
    {
103
        return (int)$this->externalId;
104
    }
105
106
    /**
107
     * @param int $externalId
108
     * @return Tag
109
     */
110
    public function setExternalId(int $externalId)
111
    {
112
        $this->externalId = $externalId;
113
        return $this;
114
    }
115
116
    /**
117
     * @return null|string
118
     */
119
    public function getSelectorType()
120
    {
121
        return $this->selectorType;
122
    }
123
124
    /**
125
     * @param null|string $selectorType
126
     * @return Tag
127
     */
128
    public function setSelectorType($selectorType)
129
    {
130
        $this->selectorType = $selectorType;
131
        return $this;
132
    }
133
134
    /**
135
     * @return int|null
136
     */
137
    public function getSortOrder()
138
    {
139
        return $this->sortOrder;
140
    }
141
142
    /**
143
     * @param int|null $sortOrder
144
     * @return Tag
145
     */
146
    public function setSortOrder($sortOrder)
147
    {
148
        $this->sortOrder = $sortOrder;
149
        return $this;
150
    }
151
152
    /**
153
     * @return ArrayCollection|TagValue[]
154
     */
155
    public function getTagValues()
156
    {
157
        return $this->tagValues;
158
    }
159
160
    /**
161
     * @param ArrayCollection|TagValue[] $tagValues
162
     * @return Tag
163
     */
164
    public function setTagValues($tagValues)
165
    {
166
        $this->tagValues = $tagValues;
167
        return $this;
168
    }
169
}