Completed
Push — master ( a0253d...70910a )
by Ryan
12:32 queued 06:51
created

Section::setLabel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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