Completed
Push — master ( f93802...a3beff )
by Paweł
34:14
created

Route::getParent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\Model;
16
17
use Doctrine\Common\Collections\ArrayCollection;
18
use Doctrine\Common\Collections\Collection;
19
use SWP\Bundle\ContentBundle\Model\RouteInterface;
20
use SWP\Component\MultiTenancy\Model\TenantAwareInterface;
21
use SWP\Component\MultiTenancy\Model\TenantAwareTrait;
22
use SWP\Bundle\ContentBundle\Model\Route as BaseRoute;
23
use SWP\Component\Storage\Model\PersistableInterface;
24
25 View Code Duplication
class Route extends BaseRoute implements
1 ignored issue
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    PersistableInterface,
27
    RouteInterface,
28
    TenantAwareInterface
29
{
30
    use TenantAwareTrait;
31
32
    /**
33
     * @var int
34
     */
35
    protected $id;
36
37
    /**
38
     * @var Collection
39
     */
40
    protected $articles;
41
42
    /**
43
     * @var RouteInterface
44
     */
45
    protected $root;
46
47
    /**
48
     * @var RouteInterface
49
     */
50
    protected $parent;
51
52
    /**
53
     * @var Collection|RouteInterface[]
54
     */
55
    protected $children;
56
57
    /**
58
     * @var int
59
     */
60
    protected $lft;
61
62
    /**
63
     * @var int
64
     */
65
    protected $rgt;
66
67
    /**
68
     * @var int
69
     */
70
    protected $level;
71
72 68
    public function __construct()
73
    {
74 68
        $this->articles = new ArrayCollection();
75 68
        $this->children = new ArrayCollection();
76
77 68
        parent::__construct();
78 68
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function getArticles()
84
    {
85
        return $this->articles;
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91
    public function setArticles($articles)
92
    {
93
        $this->articles = $articles;
94
    }
95
96
    /**
97
     * {@inheritdoc}
98
     */
99 21
    public function getId()
100
    {
101 21
        return parent::getId();
102
    }
103
104
    /**
105
     * {@inheritdoc}
106
     */
107 2
    public function getRouteName()
108
    {
109 2
        return $this->getName();
110
    }
111
112
    /**
113
     * {@inheritdoc}
114
     */
115
    public function isRoot(): bool
116
    {
117
        return null === $this->parent;
118
    }
119
120
    /**
121
     * {@inheritdoc}
122
     */
123
    public function getRoot(): RouteInterface
124
    {
125
        return $this->root;
126
    }
127
128
    /**
129
     * {@inheritdoc}
130
     */
131 21
    public function getParent()
132
    {
133 21
        return $this->parent;
134
    }
135
136
    /**
137
     * {@inheritdoc}
138
     */
139
    public function setParent(RouteInterface $parent = null)
140
    {
141
        $this->parent = $parent;
142
    }
143
144
    /**
145
     * @return Collection|RouteInterface[]
146
     */
147
    public function getChildren()
148
    {
149
        return $this->children;
150
    }
151
152
    /**
153
     * {@inheritdoc}
154
     */
155
    public function hasChild(RouteInterface $route): bool
156
    {
157
        return $this->children->contains($route);
158
    }
159
160
    /**
161
     * {@inheritdoc}
162
     */
163
    public function addChild(RouteInterface $route)
164
    {
165
        if (!$this->hasChild($route)) {
166
            $route->setParent($this);
167
            $this->children->add($route);
168
        }
169
    }
170
171
    /**
172
     * {@inheritdoc}
173
     */
174
    public function removeChild(RouteInterface $route)
175
    {
176
        if ($this->hasChild($route)) {
177
            $route->setParent(null);
178
            $this->children->removeElement($route);
179
        }
180
    }
181
182
    /**
183
     * {@inheritdoc}
184
     */
185
    public function getLeft(): int
186
    {
187
        return $this->lft;
188
    }
189
190
    /**
191
     * {@inheritdoc}
192
     */
193
    public function setLeft(int $left)
194
    {
195
        $this->lft = $left;
196
    }
197
198
    /**
199
     * {@inheritdoc}
200
     */
201
    public function getRight(): int
202
    {
203
        return $this->rgt;
204
    }
205
206
    /**
207
     * @param int $right
208
     */
209
    public function setRight(int $right)
210
    {
211
        $this->rgt = $right;
212
    }
213
214
    /**
215
     * {@inheritdoc}
216
     */
217
    public function getLevel(): int
218
    {
219
        return $this->level;
220
    }
221
222
    /**
223
     * {@inheritdoc}
224
     */
225
    public function setLevel(int $level)
226
    {
227
        $this->level = $level;
228
    }
229
}
230