Device   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 188
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 28.26%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 18
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 188
ccs 13
cts 46
cp 0.2826
rs 10

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getState() 0 10 2
A getParams() 0 4 1
A setParams() 0 5 1
A getActions() 0 4 1
A setActions() 0 5 1
A getId() 0 4 1
A setId() 0 5 1
A getName() 0 4 1
A getAlias() 0 4 1
A getType() 0 4 1
A setType() 0 5 1
A __toString() 0 4 1
A setName() 0 5 1
A setAlias() 0 5 1
A setState() 0 16 3
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Entity
9
 * @ORM\Table(name="devices")
10
 */
11
class Device
12
{
13
14
    /**
15
     * @ORM\Column(type="integer")
16
     * @ORM\Id
17
     * @ORM\GeneratedValue(strategy="AUTO")
18
     */
19
    private $id;
20
21
    /**
22
     * @ORM\Column(type="string", length=100)
23
     */
24
    private $name;
25
26
    /**
27
     * @ORM\Column(type="string", length=100)
28
     */
29
    private $alias;
30
    /**
31
     * @ORM\Column(type="simple_array", nullable=true)
32
     */
33
    private $type;
34
35
    /**
36
     * @ORM\Column(type="simple_array", nullable=true)
37
     */
38
    private $params;
39
40
    /**
41
     * @ORM\Column(type="simple_array", nullable=true)
42
     */
43
    private $state = [];
44
45
    /**
46
     * @return mixed
47
     */
48
    public function getState()
49
    {
50
        $tmp = [];
51
        foreach ($this->state as $key => $value) {
52
            $value = explode(':', $value);
53
            $tmp[$value[0]] = $value[1];
54
        }
55
56
        return $tmp;
57
    }
58
59
    /**
60
     * @param mixed $state
61
     * @return Device
62
     */
63 1
    public function setState($state)
64
    {
65
66 1
        $tmp = [];
67
68 1
        foreach ($state as $key => $value) {
69 1
            if (is_numeric($key)) {
70
                $tmp[] = $value;
71
            } else {
72 1
                $tmp[] = $key.':'.$value;
73
            }
74
        }
75
76 1
        $this->state = $tmp;
77 1
        return $this;
78
    }
79
80
    /**
81
     * @return mixed
82
     */
83
    public function getParams()
84
    {
85
        return $this->params;
86
    }
87
88
    /**
89
     * @param mixed $params
90
     * @return Device
91
     */
92
    public function setParams($params)
93
    {
94
        $this->params = $params;
95
        return $this;
96
    }
97
98
    /**
99
     * @return [Action]
0 ignored issues
show
Documentation introduced by
The doc-type [Action] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
100
     */
101
    public function getActions()
102
    {
103
        return $this->actions;
104
    }
105
106
    /**
107
     * @param mixed $actions
108
     * @return Device
109
     */
110
    public function setActions($actions)
111
    {
112
        $this->actions = $actions;
113
        return $this;
114
    }
115
116
    /**
117
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\Action", mappedBy="device")
118
     */
119
    private $actions;
120
121
122
    /**
123
     * @return mixed
124
     */
125
    public function getId()
126
    {
127
        return $this->id;
128
    }
129
130
    /**
131
     * @param mixed $id
132
     * @return Device
133
     */
134
    public function setId($id)
135
    {
136
        $this->id = $id;
137
        return $this;
138
    }
139
140
    /**
141
     * @return mixed
142
     */
143
    public function getName()
144
    {
145
        return $this->name;
146
    }
147
148
    /**
149
     * @param string $name
150
     * @return Device
151
     */
152 1
    public function setName($name)
153
    {
154 1
        $this->name = $name;
155 1
        return $this;
156
    }
157
158
    /**
159
     * @return mixed
160
     */
161
    public function getAlias()
162
    {
163
        return $this->alias;
164
    }
165
166
    /**
167
     * @param string $alias
168
     * @return Device
169
     */
170 1
    public function setAlias($alias)
171
    {
172 1
        $this->alias = $alias;
173 1
        return $this;
174
    }
175
176
    /**
177
     * @return mixed
178
     */
179
    public function getType()
180
    {
181
        return $this->type;
182
    }
183
184
    /**
185
     * @param mixed $type
186
     * @return Device
187
     */
188
    public function setType($type)
189
    {
190
        $this->type = $type;
191
        return $this;
192
    }
193
194
    public function __toString()
195
    {
196
        return $this->getName().' ('.implode(', ', $this->getType()).')';
197
    }
198
}
199