Completed
Push — master ( a8e483...64d461 )
by Ryan
08:20
created

Section::isSubSection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Anomaly\Streams\Platform\Ui\ControlPanel\Component\Section;
2
3
use Anomaly\Streams\Platform\Ui\ControlPanel\Component\Section\Contract\SectionInterface;
4
5
/**
6
 * Class Section
7
 *
8
 * @link          http://anomaly.is/streams-platform
9
 * @author        AnomalyLabs, Inc. <[email protected]>
10
 * @author        Ryan Thompson <[email protected]>
11
 * @package       Anomaly\Streams\Platform\Ui\ControlPanel\Component\Section
12
 */
13
class Section implements SectionInterface
14
{
15
16
    /**
17
     * The section slug.
18
     *
19
     * @var null|string
20
     */
21
    protected $slug = null;
22
23
    /**
24
     * The section icon.
25
     *
26
     * @var null|string
27
     */
28
    protected $icon = null;
29
30
    /**
31
     * The section title.
32
     *
33
     * @var null|string
34
     */
35
    protected $title = null;
36
37
    /**
38
     * The class.
39
     *
40
     * @var null|string
41
     */
42
    protected $class = null;
43
44
    /**
45
     * The active flag.
46
     *
47
     * @var bool
48
     */
49
    protected $active = false;
50
51
    /**
52
     * The path matcher.
53
     *
54
     * @var null|string
55
     */
56
    protected $matcher = null;
57
58
    /**
59
     * The section description.
60
     *
61
     * @var null|string
62
     */
63
    protected $description = null;
64
65
    /**
66
     * The highlighted flag.
67
     *
68
     * @var bool
69
     */
70
    protected $highlighted = false;
71
72
    /**
73
     * The section parent.
74
     *
75
     * @var null|string
76
     */
77
    protected $parent = null;
78
79
    /**
80
     * Section buttons. These are only to
81
     * transport input to the button builder.
82
     *
83
     * @var array
84
     */
85
    protected $buttons = [];
86
87
    /**
88
     * The section attributes.
89
     *
90
     * @var array
91
     */
92
    protected $attributes = [];
93
94
    /**
95
     * The section permission.
96
     *
97
     * @var null|string
98
     */
99
    protected $permission = null;
100
101
    /**
102
     * The section breadcrumb.
103
     *
104
     * @var null|string
105
     */
106
    protected $breadcrumb = null;
107
108
    /**
109
     * Get the slug.
110
     *
111
     * @return null|string
112
     */
113
    public function getSlug()
114
    {
115
        return $this->slug;
116
    }
117
118
    /**
119
     * Set the slug.
120
     *
121
     * @param $slug
122
     * @return $this
123
     */
124
    public function setSlug($slug)
125
    {
126
        $this->slug = $slug;
127
128
        return $this;
129
    }
130
131
    /**
132
     * Get the icon.
133
     *
134
     * @return null|string
135
     */
136
    public function getIcon()
137
    {
138
        return $this->icon;
139
    }
140
141
    /**
142
     * Set the icon.
143
     *
144
     * @param $icon
145
     * @return $this
146
     */
147
    public function setIcon($icon)
148
    {
149
        $this->icon = $icon;
150
151
        return $this;
152
    }
153
154
    /**
155
     * Get the title.
156
     *
157
     * @return string
158
     */
159
    public function getTitle()
160
    {
161
        return $this->title;
162
    }
163
164
    /**
165
     * Set the title.
166
     *
167
     * @param string $title
168
     */
169
    public function setTitle($title)
170
    {
171
        $this->title = $title;
172
    }
173
174
    /**
175
     * Get the class.
176
     *
177
     * @return string
178
     */
179
    public function getClass()
180
    {
181
        return $this->class;
182
    }
183
184
    /**
185
     * Set the class.
186
     *
187
     * @param $class
188
     * @return $this
189
     */
190
    public function setClass($class)
191
    {
192
        $this->class = $class;
193
194
        return $this;
195
    }
196
197
    /**
198
     * Get the active flag.
199
     *
200
     * @return boolean
201
     */
202
    public function isActive()
203
    {
204
        return $this->active;
205
    }
206
207
    /**
208
     * Set the active flag.
209
     *
210
     * @param boolean $active
211
     */
212
    public function setActive($active)
213
    {
214
        $this->active = $active;
215
216
        return $this;
217
    }
218
219
    /**
220
     * Get the matcher.
221
     *
222
     * @return null|string
223
     */
224
    public function getMatcher()
225
    {
226
        return $this->matcher;
227
    }
228
229
    /**
230
     * Set the matcher.
231
     *
232
     * @param $matcher
233
     * @return $this
234
     */
235
    public function setMatcher($matcher)
236
    {
237
        $this->matcher = $matcher;
238
239
        return $this;
240
    }
241
242
    /**
243
     * Get the description.
244
     *
245
     * @return null|string
246
     */
247
    public function getDescription()
248
    {
249
        return $this->description;
250
    }
251
252
    /**
253
     * Set the description.
254
     *
255
     * @param $description
256
     * @return $this
257
     */
258
    public function setDescription($description)
259
    {
260
        $this->description = $description;
261
262
        return $this;
263
    }
264
265
    /**
266
     * Get the highlighted flag.
267
     *
268
     * @return boolean
269
     */
270
    public function isHighlighted()
271
    {
272
        return $this->highlighted;
273
    }
274
275
    /**
276
     * Set the highlighted flag.
277
     *
278
     * @param boolean $active
0 ignored issues
show
Bug introduced by
There is no parameter named $active. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
279
     * @return $this
280
     */
281
    public function setHighlighted($highlighted)
282
    {
283
        $this->highlighted = $highlighted;
284
285
        return $this;
286
    }
287
288
    /**
289
     * Get the parent.
290
     *
291
     * @return null|string
292
     */
293
    public function getParent()
294
    {
295
        return $this->parent;
296
    }
297
298
    /**
299
     * Return if the section is
300
     * a sub-section or not.
301
     *
302
     * @return bool
303
     */
304
    public function isSubSection()
305
    {
306
        return (bool)$this->getParent();
307
    }
308
309
    /**
310
     * Set the parent.
311
     *
312
     * @param $parent
313
     * @return $this
314
     */
315
    public function setParent($parent)
316
    {
317
        $this->parent = $parent;
318
319
        return $this;
320
    }
321
322
    /**
323
     * Get the buttons.
324
     *
325
     * @return array
326
     */
327
    public function getButtons()
328
    {
329
        return $this->buttons;
330
    }
331
332
    /**
333
     * Set the buttons.
334
     *
335
     * @param array $buttons
336
     */
337
    public function setButtons($buttons)
338
    {
339
        $this->buttons = $buttons;
340
    }
341
342
    /**
343
     * Get the attributes.
344
     *
345
     * @return array
346
     */
347
    public function getAttributes()
348
    {
349
        return $this->attributes;
350
    }
351
352
    /**
353
     * Set the attributes.
354
     *
355
     * @param array $attributes
356
     */
357
    public function setAttributes(array $attributes)
358
    {
359
        $this->attributes = $attributes;
360
    }
361
362
    /**
363
     * Get the permission.
364
     *
365
     * @return null|string
366
     */
367
    public function getPermission()
368
    {
369
        return $this->permission;
370
    }
371
372
    /**
373
     * Set the permission.
374
     *
375
     * @param $permission
376
     * @return $this
377
     */
378
    public function setPermission($permission)
379
    {
380
        $this->permission = $permission;
381
382
        return $this;
383
    }
384
385
    /**
386
     * Get the breadcrumb.
387
     *
388
     * @return null|string
389
     */
390
    public function getBreadcrumb()
391
    {
392
        return $this->breadcrumb;
393
    }
394
395
    /**
396
     * Set the breadcrumb.
397
     *
398
     * @param $breadcrumb
399
     * @return $this
400
     */
401
    public function setBreadcrumb($breadcrumb)
402
    {
403
        $this->breadcrumb = $breadcrumb;
404
405
        return $this;
406
    }
407
408
    /**
409
     * Get the HREF attribute.
410
     *
411
     * @param null $path
412
     * @return string
413
     */
414
    public function getHref($path = null)
415
    {
416
        return array_get(
417
            $this->attributes,
418
            'data-href',
419
            array_get($this->attributes, 'href')
420
        ) . ($path ? '/' . $path : $path);
421
    }
422
423
    /**
424
     * Return the child sections.
425
     *
426
     * @return SectionCollection
427
     */
428
    public function getChildren()
429
    {
430
        return app(SectionCollection::class)->children($this->getSlug());
431
    }
432
433
    /**
434
     * Return whether the section
435
     * has children or not.
436
     *
437
     * @return bool
438
     */
439
    public function hasChildren()
440
    {
441
        return !$this->getChildren()->isEmpty();
442
    }
443
}
444