FakeUserParentParent::removeTag()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
namespace Thunder\Serializard\Tests\Fake;
3
4
class FakeUserParentParent
5
{
6
    protected $id;
7
    protected $name;
8
    protected $tag;
9
    /** @var FakeTag[] */
10
    protected $tags = [];
11
12
    public function __construct($id, $name, FakeTag $tag)
13
    {
14
        $this->id = $id;
15
        $this->name = $name;
16
        $this->tag = $tag;
17
    }
18
19
    public function setId($id) { $this->id = $id; return $this; }
20
    public function getId() { return $this->id; }
21
22
    public function setName($name) { $this->name = $name; return $this; }
23
    public function getName() { return $this->name; }
24
25
    public function getTag() { return $this->tag; }
26
27
    public function addTag(FakeTag $tag)
28
    {
29
        $tag->setUser($this);
30
31
        $this->tags[] = $tag;
32
    }
33
34
    public function removeTag(FakeTag $removed)
35
    {
36
        foreach($this->tags as $key => $tag) {
37
            if($removed->getName() === $tag->getName()) {
38
                unset($this->tags[$key]);
39
            }
40
        }
41
    }
42
43
    public function getTags() { return $this->tags; }
44
}
45