Completed
Push — master ( f91e5f...af813c )
by Ryan
07:45
created

Section::hasChildren()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
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 permalink.
60
     *
61
     * @var null|string
62
     */
63
    protected $permalink = null;
64
65
    /**
66
     * The section description.
67
     *
68
     * @var null|string
69
     */
70
    protected $description = null;
71
72
    /**
73
     * The highlighted flag.
74
     *
75
     * @var bool
76
     */
77
    protected $highlighted = false;
78
79
    /**
80
     * The section parent.
81
     *
82
     * @var null|string
83
     */
84
    protected $parent = null;
85
86
    /**
87
     * Section buttons. These are only to
88
     * transport input to the button builder.
89
     *
90
     * @var array
91
     */
92
    protected $buttons = [];
93
94
    /**
95
     * The section attributes.
96
     *
97
     * @var array
98
     */
99
    protected $attributes = [];
100
101
    /**
102
     * The section permission.
103
     *
104
     * @var null|string
105
     */
106
    protected $permission = null;
107
108
    /**
109
     * The section breadcrumb.
110
     *
111
     * @var null|string
112
     */
113
    protected $breadcrumb = null;
114
115
    /**
116
     * Get the slug.
117
     *
118
     * @return null|string
119
     */
120
    public function getSlug()
121
    {
122
        return $this->slug;
123
    }
124
125
    /**
126
     * Set the slug.
127
     *
128
     * @param $slug
129
     * @return $this
130
     */
131
    public function setSlug($slug)
132
    {
133
        $this->slug = $slug;
134
135
        return $this;
136
    }
137
138
    /**
139
     * Get the icon.
140
     *
141
     * @return null|string
142
     */
143
    public function getIcon()
144
    {
145
        return $this->icon;
146
    }
147
148
    /**
149
     * Set the icon.
150
     *
151
     * @param $icon
152
     * @return $this
153
     */
154
    public function setIcon($icon)
155
    {
156
        $this->icon = $icon;
157
158
        return $this;
159
    }
160
161
    /**
162
     * Get the title.
163
     *
164
     * @return string
165
     */
166
    public function getTitle()
167
    {
168
        return $this->title;
169
    }
170
171
    /**
172
     * Set the title.
173
     *
174
     * @param string $title
175
     */
176
    public function setTitle($title)
177
    {
178
        $this->title = $title;
179
    }
180
181
    /**
182
     * Get the class.
183
     *
184
     * @return string
185
     */
186
    public function getClass()
187
    {
188
        return $this->class;
189
    }
190
191
    /**
192
     * Set the class.
193
     *
194
     * @param $class
195
     * @return $this
196
     */
197
    public function setClass($class)
198
    {
199
        $this->class = $class;
200
201
        return $this;
202
    }
203
204
    /**
205
     * Get the active flag.
206
     *
207
     * @return boolean
208
     */
209
    public function isActive()
210
    {
211
        return $this->active;
212
    }
213
214
    /**
215
     * Set the active flag.
216
     *
217
     * @param boolean $active
218
     */
219
    public function setActive($active)
220
    {
221
        $this->active = $active;
222
223
        return $this;
224
    }
225
226
    /**
227
     * Get the matcher.
228
     *
229
     * @return null|string
230
     */
231
    public function getMatcher()
232
    {
233
        return $this->matcher;
234
    }
235
236
    /**
237
     * Set the matcher.
238
     *
239
     * @param $matcher
240
     * @return $this
241
     */
242
    public function setMatcher($matcher)
243
    {
244
        $this->matcher = $matcher;
245
246
        return $this;
247
    }
248
249
    /**
250
     * Get the permalink.
251
     *
252
     * @return null|string
253
     */
254
    public function getPermalink()
255
    {
256
        return $this->permalink;
257
    }
258
259
    /**
260
     * Set the permalink.
261
     *
262
     * @param $permalink
263
     * @return $this
264
     */
265
    public function setPermalink($permalink)
266
    {
267
        $this->permalink = $permalink;
268
269
        return $this;
270
    }
271
272
    /**
273
     * Get the description.
274
     *
275
     * @return null|string
276
     */
277
    public function getDescription()
278
    {
279
        return $this->description;
280
    }
281
282
    /**
283
     * Set the description.
284
     *
285
     * @param $description
286
     * @return $this
287
     */
288
    public function setDescription($description)
289
    {
290
        $this->description = $description;
291
292
        return $this;
293
    }
294
295
    /**
296
     * Get the highlighted flag.
297
     *
298
     * @return boolean
299
     */
300
    public function isHighlighted()
301
    {
302
        return $this->highlighted;
303
    }
304
305
    /**
306
     * Set the highlighted flag.
307
     *
308
     * @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...
309
     * @return $this
310
     */
311
    public function setHighlighted($highlighted)
312
    {
313
        $this->highlighted = $highlighted;
314
315
        return $this;
316
    }
317
318
    /**
319
     * Get the parent.
320
     *
321
     * @return null|string
322
     */
323
    public function getParent()
324
    {
325
        return $this->parent;
326
    }
327
328
    /**
329
     * Return if the section is
330
     * a sub-section or not.
331
     *
332
     * @return bool
333
     */
334
    public function isSubSection()
335
    {
336
        return (bool)$this->getParent();
337
    }
338
339
    /**
340
     * Set the parent.
341
     *
342
     * @param $parent
343
     * @return $this
344
     */
345
    public function setParent($parent)
346
    {
347
        $this->parent = $parent;
348
349
        return $this;
350
    }
351
352
    /**
353
     * Get the buttons.
354
     *
355
     * @return array
356
     */
357
    public function getButtons()
358
    {
359
        return $this->buttons;
360
    }
361
362
    /**
363
     * Set the buttons.
364
     *
365
     * @param array $buttons
366
     */
367
    public function setButtons($buttons)
368
    {
369
        $this->buttons = $buttons;
370
    }
371
372
    /**
373
     * Get the attributes.
374
     *
375
     * @return array
376
     */
377
    public function getAttributes()
378
    {
379
        return $this->attributes;
380
    }
381
382
    /**
383
     * Set the attributes.
384
     *
385
     * @param array $attributes
386
     */
387
    public function setAttributes(array $attributes)
388
    {
389
        $this->attributes = $attributes;
390
    }
391
392
    /**
393
     * Get the permission.
394
     *
395
     * @return null|string
396
     */
397
    public function getPermission()
398
    {
399
        return $this->permission;
400
    }
401
402
    /**
403
     * Set the permission.
404
     *
405
     * @param $permission
406
     * @return $this
407
     */
408
    public function setPermission($permission)
409
    {
410
        $this->permission = $permission;
411
412
        return $this;
413
    }
414
415
    /**
416
     * Get the breadcrumb.
417
     *
418
     * @return null|string
419
     */
420
    public function getBreadcrumb()
421
    {
422
        return $this->breadcrumb;
423
    }
424
425
    /**
426
     * Set the breadcrumb.
427
     *
428
     * @param $breadcrumb
429
     * @return $this
430
     */
431
    public function setBreadcrumb($breadcrumb)
432
    {
433
        $this->breadcrumb = $breadcrumb;
434
435
        return $this;
436
    }
437
438
    /**
439
     * Get the HREF attribute.
440
     *
441
     * @param null $path
442
     * @return string
443
     */
444
    public function getHref($path = null)
445
    {
446
        return ($this->getPermalink() ?: array_get($this->attributes, 'href')) . ($path ? '/' . $path : $path);
447
    }
448
449
    /**
450
     * Return the child sections.
451
     *
452
     * @return SectionCollection
453
     */
454
    public function getChildren()
455
    {
456
        return app(SectionCollection::class)->children($this->getSlug());
457
    }
458
459
    /**
460
     * Return whether the section
461
     * has children or not.
462
     *
463
     * @return bool
464
     */
465
    public function hasChildren()
466
    {
467
        return !$this->getChildren()->isEmpty();
468
    }
469
}
470