Completed
Push — master ( 98a062...441031 )
by Ryan
10:10
created

NavigationLink::icon()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 4
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Anomaly\Streams\Platform\Ui\ControlPanel\Component\Navigation;
2
3
use Anomaly\Streams\Platform\Asset\Asset;
4
use Anomaly\Streams\Platform\Image\Image;
5
use Anomaly\Streams\Platform\Ui\ControlPanel\Component\Navigation\Contract\NavigationLinkInterface;
6
use Anomaly\Streams\Platform\Ui\Icon\Command\GetIcon;
7
use Anomaly\Streams\Platform\Ui\Icon\IconRegistry;
8
use Illuminate\Foundation\Bus\DispatchesJobs;
9
10
/**
11
 * Class NavigationLink
12
 *
13
 * @link   http://pyrocms.com/
14
 * @author PyroCMS, Inc. <[email protected]>
15
 * @author Ryan Thompson <[email protected]>
16
 */
17
class NavigationLink implements NavigationLinkInterface
18
{
19
20
    use DispatchesJobs;
21
22
    /**
23
     * The links slug.
24
     *
25
     * @var null|string
26
     */
27
    protected $slug = null;
28
29
    /**
30
     * The link icon.
31
     *
32
     * @var null|string
33
     */
34
    protected $icon = null;
35
36
    /**
37
     * The links title.
38
     *
39
     * @var null|string
40
     */
41
    protected $title = 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 favorite flag.
59
     *
60
     * @var bool
61
     */
62
    protected $favorite = false;
63
64
    /**
65
     * The links attributes.
66
     *
67
     * @var array
68
     */
69
    protected $attributes = [];
70
71
    /**
72
     * The links permission.
73
     *
74
     * @var null|string
75
     */
76
    protected $permission = null;
77
78
    /**
79
     * The links breadcrumb.
80
     *
81
     * @var null|string
82
     */
83
    protected $breadcrumb = null;
84
85
    /**
86
     * @var Image
87
     */
88
    protected $image;
89
90
    /**
91
     * @var Asset
92
     */
93
    protected $asset;
94
95
    /**
96
     * Create a new NavigationLink instance.
97
     *
98
     * @param Image        $image
99
     * @param Asset        $asset
100
     * @param IconRegistry $icons
0 ignored issues
show
Bug introduced by
There is no parameter named $icons. 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...
101
     */
102
    public function __construct(Image $image, Asset $asset)
103
    {
104
        $this->image = $image;
105
        $this->asset = $asset;
106
    }
107
108
    public function icon($default = 'fa fa-puzzle-piece')
109
    {
110
        $icon = $this->getIcon() ?: $default;
111
112
        if (ends_with($icon, '.svg')) {
113
            return $this->image->make($icon)->data();
114
        }
115
116
        return $this->dispatch(new GetIcon($icon));
117
    }
118
119
    /**
120
     * Get the slug.
121
     *
122
     * @return null|string
123
     */
124
    public function getSlug()
125
    {
126
        return $this->slug;
127
    }
128
129
    /**
130
     * Set the slug.
131
     *
132
     * @param $slug
133
     * @return $this
134
     */
135
    public function setSlug($slug)
136
    {
137
        $this->slug = $slug;
138
139
        return $this;
140
    }
141
142
    /**
143
     * Get the icon.
144
     *
145
     * @return null|string
146
     */
147
    public function getIcon()
148
    {
149
        return $this->icon;
150
    }
151
152
    /**
153
     * Set the icon.
154
     *
155
     * @param $icon
156
     * @return $this
157
     */
158
    public function setIcon($icon)
159
    {
160
        $this->icon = $icon;
161
162
        return $this;
163
    }
164
165
    /**
166
     * Get the title.
167
     *
168
     * @return string
169
     */
170
    public function getTitle()
171
    {
172
        return $this->title;
173
    }
174
175
    /**
176
     * Set the title.
177
     *
178
     * @param string $title
179
     */
180
    public function setTitle($title)
181
    {
182
        $this->title = $title;
183
    }
184
185
    /**
186
     * Get the class.
187
     *
188
     * @return string
189
     */
190
    public function getClass()
191
    {
192
        return $this->class;
193
    }
194
195
    /**
196
     * Set the class.
197
     *
198
     * @param $class
199
     * @return $this
200
     */
201
    public function setClass($class)
202
    {
203
        $this->class = $class;
204
205
        return $this;
206
    }
207
208
    /**
209
     * Get the active flag.
210
     *
211
     * @return boolean
212
     */
213
    public function isActive()
214
    {
215
        return $this->active;
216
    }
217
218
    /**
219
     * Set the active flag.
220
     *
221
     * @param boolean $active
222
     */
223
    public function setActive($active)
224
    {
225
        $this->active = $active;
226
227
        return $this;
228
    }
229
230
    /**
231
     * Get the favorite flag.
232
     *
233
     * @return boolean
234
     */
235
    public function isFavorite()
236
    {
237
        return $this->favorite;
238
    }
239
240
    /**
241
     * Set the favorite flag.
242
     *
243
     * @param boolean $favorite
244
     */
245
    public function setFavorite($favorite)
246
    {
247
        $this->favorite = $favorite;
248
249
        return $this;
250
    }
251
252
    /**
253
     * Get the attributes.
254
     *
255
     * @return array
256
     */
257
    public function getAttributes()
258
    {
259
        return $this->attributes;
260
    }
261
262
    /**
263
     * Set the attributes.
264
     *
265
     * @param array $attributes
266
     */
267
    public function setAttributes(array $attributes)
268
    {
269
        $this->attributes = $attributes;
270
    }
271
272
    /**
273
     * Get the permission.
274
     *
275
     * @return null|string
276
     */
277
    public function getPermission()
278
    {
279
        return $this->permission;
280
    }
281
282
    /**
283
     * Set the permission.
284
     *
285
     * @param $permission
286
     * @return $this
287
     */
288
    public function setPermission($permission)
289
    {
290
        $this->permission = $permission;
291
292
        return $this;
293
    }
294
295
    /**
296
     * Get the breadcrumb.
297
     *
298
     * @return null|string
299
     */
300
    public function getBreadcrumb()
301
    {
302
        return $this->breadcrumb;
303
    }
304
305
    /**
306
     * Set the breadcrumb.
307
     *
308
     * @param $breadcrumb
309
     * @return $this
310
     */
311
    public function setBreadcrumb($breadcrumb)
312
    {
313
        $this->breadcrumb = $breadcrumb;
314
315
        return $this;
316
    }
317
318
    /**
319
     * Get the HREF attribute.
320
     *
321
     * @param  null $path
322
     * @return string
323
     */
324
    public function getHref($path = null)
325
    {
326
        return array_get($this->attributes, 'href') . ($path ? '/' . $path : $path);
327
    }
328
}
329