Completed
Push — master ( 5ba1dc...b85ec4 )
by Tomasz
02:09
created

FakeUserParentParent   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 11
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 41
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setId() 0 1 1
A getId() 0 1 1
A setName() 0 1 1
A getName() 0 1 1
A getTag() 0 1 1
A addTag() 0 6 1
A removeTag() 0 8 3
A getTags() 0 1 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 = array();
11
12
    function __construct($id, $name, FakeTag $tag)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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