Completed
Push — SF4 ( afa613...cbb2b6 )
by Laurent
05:34
created

FamilyLog   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 234
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 17
lcom 2
cbo 1
dl 0
loc 234
rs 10
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A __toString() 0 4 1
A getSlug() 0 4 1
A setParent() 0 6 1
A getParent() 0 4 1
A addChild() 0 6 1
A removeChild() 0 4 1
A getChildren() 0 4 1
A __construct() 0 4 1
A setPath() 0 6 1
A getPath() 0 4 1
A setLevel() 0 6 1
A getLevel() 0 4 1
A getIndentedName() 0 10 2
1
<?php
2
3
/**
4
 * Entity FamilyLog.
5
 *
6
 * PHP Version 7
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2018 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: $Id$
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
namespace App\Entity\Settings\Diverse;
17
18
use Doctrine\ORM\Mapping as ORM;
19
use Gedmo\Mapping\Annotation as Gedmo;
20
21
/**
22
 * FamilyLog Entity.
23
 *
24
 * @category Entity
25
 *
26
 * @ORM\Table(name="app_familylog")
27
 * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\MaterializedPathRepository")
28
 * @Gedmo\Tree(type="materializedPath")
29
 */
30
class FamilyLog
31
{
32
    /**
33
     * @var int Logistic family id
34
     *
35
     * @ORM\Column(name="id", type="integer")
36
     * @ORM\Id
37
     * @ORM\GeneratedValue(strategy="AUTO")
38
     */
39
    private $id;
40
41
    /**
42
     * @Gedmo\TreePath
43
     * @ORM\Column(length=3000, nullable=true)
44
     */
45
    private $path;
46
47
    /**
48
     * @Gedmo\TreePathSource
49
     * @var string Logistic family name
50
     *
51
     * @ORM\Column(name="name", type="string", length=255)
52
     */
53
    private $name;
54
    
55
    /**
56
     * @var string Slug name
57
     * @Gedmo\Slug(fields={"name"})
58
     * @ORM\Column(length=128, unique=true)
59
     */
60
    private $slug;
61
62
    /**
63
     * @Gedmo\TreeParent
64
     * @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\FamilyLog", inversedBy="children")
65
     * @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
66
     */
67
    private $parent;
68
69
    /**
70
     * @Gedmo\TreeLevel
71
     * @ORM\Column(type="integer", nullable=true)
72
     */
73
    private $level;
74
75
    /**
76
     * @ORM\OneToMany(targetEntity="App\Entity\Settings\Diverse\FamilyLog", mappedBy="parent")
77
     */
78
    private $children;
79
80
81
    /**
82
     * Get id.
83
     *
84
     * @return int
85
     */
86
    public function getId()
87
    {
88
        return $this->id;
89
    }
90
91
    /**
92
     * Set name.
93
     *
94
     * @param string $name Designation
95
     *
96
     * @return FamilyLog
97
     */
98
    public function setName($name)
99
    {
100
        $this->name = $name;
101
102
        return $this;
103
    }
104
105
    /**
106
     * Get name.
107
     *
108
     * @return string
109
     */
110
    public function getName()
111
    {
112
        return $this->name;
113
    }
114
115
    /**
116
     * This method allows to do "echo $familyLog".
117
     * <p> So, to "show" $familyLog,
118
     * PHP will actually show the return of this method.<br />
119
     * Here, the name, so "echo $ familyLog"
120
     * is equivalent to "echo $familyLog->getName ()"</p>.
121
     *
122
     * @return string name
123
     */
124
    public function __toString()
125
    {
126
        return $this->name;
127
    }
128
129
    /**
130
     * Get slug
131
     *
132
     * @return string
133
     */
134
    public function getSlug()
135
    {
136
        return $this->slug;
137
    }
138
139
    /**
140
     * Set parent
141
     *
142
     * @param null|\App\Entity\Settings\Diverse\FamilyLog $parent
143
     * @return FamilyLog
144
     */
145
    public function setParent(\App\Entity\Settings\Diverse\FamilyLog $parent = null)
146
    {
147
        $this->parent = $parent;
148
149
        return $this;
150
    }
151
152
    /**
153
     * Get parent
154
     *
155
     * @return \App\Entity\Settings\Diverse\FamilyLog|null
156
     */
157
    public function getParent()
158
    {
159
        return $this->parent;
160
    }
161
162
    /**
163
     * Add children
164
     *
165
     * @param \App\Entity\Settings\Diverse\FamilyLog $children
166
     * @return FamilyLog
167
     */
168
    public function addChild(\App\Entity\Settings\Diverse\FamilyLog $children)
169
    {
170
        $this->children[] = $children;
171
172
        return $this;
173
    }
174
175
    /**
176
     * Remove children
177
     *
178
     * @param \App\Entity\Settings\Diverse\FamilyLog $children
179
     */
180
    public function removeChild(\App\Entity\Settings\Diverse\FamilyLog $children)
181
    {
182
        $this->children->removeElement($children);
183
    }
184
185
    /**
186
     * Get children
187
     *
188
     * @return \App\Entity\Settings\Diverse\FamilyLog[]|\Doctrine\Common\Collections\ArrayCollection
189
     */
190
    public function getChildren()
191
    {
192
        return $this->children;
193
    }
194
    /**
195
     * Constructor
196
     */
197
    public function __construct()
198
    {
199
        $this->children = new \Doctrine\Common\Collections\ArrayCollection();
200
    }
201
202
    /**
203
     * Set path
204
     *
205
     * @param string $path
206
     * @return \App\Entity\Settings\Diverse\FamilyLog
207
     */
208
    public function setPath($path)
209
    {
210
        $this->path = $path;
211
212
        return $this;
213
    }
214
215
    /**
216
     * Get path
217
     *
218
     * @return string
219
     */
220
    public function getPath()
221
    {
222
        return $this->path;
223
    }
224
225
    /**
226
     * Set level
227
     *
228
     * @param integer $level
229
     * @return \App\Entity\Settings\Diverse\FamilyLog
230
     */
231
    public function setLevel($level)
232
    {
233
        $this->level = $level;
234
235
        return $this;
236
    }
237
238
    /**
239
     * Get level
240
     *
241
     * @return integer
242
     */
243
    public function getLevel()
244
    {
245
        return $this->level;
246
    }
247
    
248
    /**
249
     * Allows hierachy display.
250
     *
251
     * @return string
252
     */
253
    public function getIndentedName()
254
    {
255
        if ($this->parent !== null) {
256
            $return = '|-- '.$this->name;
257
        } else {
258
            $return = '- '.$this->name;
259
        }
260
261
        return $return;
262
    }
263
}
264