Test Setup Failed
Pull Request — master (#32)
by
unknown
35:47
created

FontAwesome::ul()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * FontAwesome.php
4
 * @author Revin Roman <[email protected]>
5
 * @author Simon Karlen <[email protected]>
6
 * @link https://rmrevin.ru
7
 */
8
9
namespace rmrevin\yii\fontawesome;
10
11
use rmrevin\yii\fontawesome\component;
12
13
/**
14
 * Class FA
15
 * @package rmrevin\yii\fontawesome
16
 */
17
class FontAwesome
18
{
19
    /**
20
     * CSS class prefix
21
     * @var string
22
     */
23
    public static $cssPrefix = 'fa';
24
25
    /**
26
     * Mapping array
27
     * @var array
28
     */
29
    protected static $fa4to5mapping = [
30
        'address-book-o' => ['far', 'address-book'],
31
        'address-card-o' => ['far', 'address-card'],
32
        'area-chart' => ['fas', 'chart-area'],
33
        'arrow-circle-o-down' => ['far', 'arrow-alt-circle-down'],
34
        'arrow-circle-o-left' => ['far', 'arrow-alt-circle-left'],
35
        'arrow-circle-o-right' => ['far', 'arrow-alt-circle-right'],
36
        'arrow-circle-o-up' => ['far', 'arrow-alt-circle-up'],
37
        'arrows-alt' => ['fas', 'expand-arrows-alt'],
38
        'arrows-h' => ['fas', 'arrows-alt-h'],
39
        'arrows-v' => ['fas', 'arrows-alt-v'],
40
        'arrows' => ['fas', 'arrows-alt'],
41
        'asl-interpreting' => ['fas', 'american-sign-language-interpreting'],
42
        'automobile' => ['fas', 'car'],
43
        'bank' => ['fas', 'university'],
44
        'bar-chart-o' => ['far', 'chart-bar'],
45
        'bar-chart' => ['far', 'chart-bar'],
46
        'bathtub' => ['fas', 'bath'],
47
        'battery-0' => ['fas', 'battery-empty'],
48
        'battery-1' => ['fas', 'battery-quarter'],
49
        'battery-2' => ['fas', 'battery-half'],
50
        'battery-3' => ['fas', 'battery-three-quarters'],
51
        'battery-4' => ['fas', 'battery-full'],
52
        'battery' => ['fas', 'battery-full'],
53
        'bell-o' => ['far', 'bell'],
54
        'bell-slash-o' => ['far', 'bell-slash'],
55
        'bitbucket-square' => ['fab', 'bitbucket'],
56
        'bitcoin' => ['fab', 'btc'],
57
        'bookmark-o' => ['far', 'bookmark'],
58
        'building-o' => ['far', 'building'],
59
        'cab' => ['fas', 'taxi'],
60
        'calendar-check-o' => ['far', 'calendar-check'],
61
        'calendar-minus-o' => ['far', 'calendar-minus'],
62
        'calendar-o' => ['far', 'calendar'],
63
        'calendar-plus-o' => ['far', 'calendar-plus'],
64
        'calendar-times-o' => ['far', 'calendar-times'],
65
        'calendar' => ['fas', 'calendar-alt'],
66
        'caret-square-o-down' => ['far', 'caret-square-down'],
67
        'caret-square-o-left' => ['far', 'caret-square-left'],
68
        'caret-square-o-right' => ['far', 'caret-square-right'],
69
        'caret-square-o-up' => ['far', 'caret-square-up'],
70
        'cc' => ['far', 'closed-captioning'],
71
        'chain-broken' => ['fas', 'unlink'],
72
        'chain' => ['fas', 'link'],
73
        'check-circle-o' => ['far', 'check-circle'],
74
        'check-square-o' => ['far', 'check-square'],
75
        'circle-o-notch' => ['fas', 'circle-notch'],
76
        'circle-o' => ['far', 'circle'],
77
        'circle-thin' => ['far', 'circle'],
78
        'clock-o' => ['far', 'clock'],
79
        'close' => ['fas', 'times'],
80
        'cloud-download' => ['fas', 'cloud-download-alt'],
81
        'cloud-upload' => ['fas', 'cloud-upload-alt'],
82
        'cny' => ['fas', 'yen-sign'],
83
        'code-fork' => ['fas', 'code-branch'],
84
        'comment-o' => ['far', 'comment'],
85
        'commenting-o' => ['far', 'comment-alt'],
86
        'commenting' => ['fas', 'comment-alt'],
87
        'comments-o' => ['far', 'comments'],
88
        'credit-card-alt' => ['fas', 'credit-card'],
89
        'cutlery' => ['fas', 'utensils'],
90
        'dashboard' => ['fas', 'tachometer-alt'],
91
        'deafness' => ['fas', 'deaf'],
92
        'dedent' => ['fas', 'outdent'],
93
        'diamond' => ['far', 'gem'],
94
        'dollar' => ['fas', 'dollar-sign'],
95
        'dot-circle-o' => ['far', 'dot-circle'],
96
        'drivers-license-o' => ['far', 'id-card'],
97
        'drivers-license' => ['fas', 'id-card'],
98
        'eercast' => ['fab', 'sellcast'],
99
        'envelope-o' => ['far', 'envelope'],
100
        'envelope-open-o' => ['far', 'envelope-open'],
101
        'eur' => ['fas', 'euro-sign'],
102
        'euro' => ['fas', 'euro-sign'],
103
        'exchange' => ['fas', 'exchange-alt'],
104
        'external-link-square' => ['fas', 'external-link-square-alt'],
105
        'external-link' => ['fas', 'external-link-alt'],
106
        'eyedropper' => ['fas', 'eye-dropper'],
107
        'fa' => ['fab', 'font-awesome'],
108
        'facebook-f' => ['fab', 'facebook-f'],
109
        'facebook-official' => ['fab', 'facebook'],
110
        'facebook' => ['fab', 'facebook-f'],
111
        'feed' => ['fas', 'rss'],
112
        'file-archive-o' => ['far', 'file-archive'],
113
        'file-audio-o' => ['far', 'file-audio'],
114
        'file-code-o' => ['far', 'file-code'],
115
        'file-excel-o' => ['far', 'file-excel'],
116
        'file-image-o' => ['far', 'file-image'],
117
        'file-movie-o' => ['far', 'file-video'],
118
        'file-o' => ['far', 'file'],
119
        'file-pdf-o' => ['far', 'file-pdf'],
120
        'file-photo-o' => ['far', 'file-image'],
121
        'file-picture-o' => ['far', 'file-image'],
122
        'file-powerpoint-o' => ['far', 'file-powerpoint'],
123
        'file-sound-o' => ['far', 'file-audio'],
124
        'file-text-o' => ['far', 'file-alt'],
125
        'file-text' => ['fas', 'file-alt'],
126
        'file-video-o' => ['far', 'file-video'],
127
        'file-word-o' => ['far', 'file-word'],
128
        'file-zip-o' => ['far', 'file-archive'],
129
        'files-o' => ['far', 'copy'],
130
        'flag-o' => ['far', 'flag'],
131
        'flash' => ['fas', 'bolt'],
132
        'floppy-o' => ['far', 'save'],
133
        'folder-o' => ['far', 'folder'],
134
        'folder-open-o' => ['far', 'folder-open'],
135
        'frown-o' => ['far', 'frown'],
136
        'futbol-o' => ['far', 'futbol'],
137
        'gbp' => ['fas', 'pound-sign'],
138
        'ge' => ['fab', 'empire'],
139
        'gear' => ['fas', 'cog'],
140
        'gears' => ['fas', 'cogs'],
141
        'gittip' => ['fab', 'gratipay'],
142
        'glass' => ['fas', 'glass-martini'],
143
        'google-plus-circle' => ['fab', 'google-plus'],
144
        'google-plus-official' => ['fab', 'google-plus'],
145
        'google-plus' => ['fab', 'google-plus-g'],
146
        'group' => ['fas', 'users'],
147
        'hand-grab-o' => ['far', 'hand-rock'],
148
        'hand-lizard-o' => ['far', 'hand-lizard'],
149
        'hand-o-down' => ['far', 'hand-point-down'],
150
        'hand-o-left' => ['far', 'hand-point-left'],
151
        'hand-o-right' => ['far', 'hand-point-right'],
152
        'hand-o-up' => ['far', 'hand-point-up'],
153
        'hand-paper-o' => ['far', 'hand-paper'],
154
        'hand-peace-o' => ['far', 'hand-peace'],
155
        'hand-pointer-o' => ['far', 'hand-pointer'],
156
        'hand-rock-o' => ['far', 'hand-rock'],
157
        'hand-scissors-o' => ['far', 'hand-scissors'],
158
        'hand-spock-o' => ['far', 'hand-spock'],
159
        'hand-stop-o' => ['far', 'hand-paper'],
160
        'handshake-o' => ['far', 'handshake'],
161
        'hard-of-hearing' => ['fas', 'deaf'],
162
        'hdd-o' => ['far', 'hdd'],
163
        'header' => ['fas', 'heading'],
164
        'heart-o' => ['far', 'heart'],
165
        'hospital-o' => ['far', 'hospital'],
166
        'hotel' => ['fas', 'bed'],
167
        'hourglass-1' => ['fas', 'hourglass-start'],
168
        'hourglass-2' => ['fas', 'hourglass-half'],
169
        'hourglass-3' => ['fas', 'hourglass-end'],
170
        'hourglass-o' => ['far', 'hourglass'],
171
        'id-card-o' => ['far', 'id-card'],
172
        'ils' => ['fas', 'shekel-sign'],
173
        'image' => ['far', 'image'],
174
        'inr' => ['fas', 'rupee-sign'],
175
        'institution' => ['fas', 'university'],
176
        'intersex' => ['fas', 'transgender'],
177
        'jpy' => ['fas', 'yen-sign'],
178
        'keyboard-o' => ['far', 'keyboard'],
179
        'krw' => ['fas', 'won-sign'],
180
        'legal' => ['fas', 'gavel'],
181
        'lemon-o' => ['far', 'lemon'],
182
        'level-down' => ['fas', 'level-down-alt'],
183
        'level-up' => ['fas', 'level-up-alt'],
184
        'life-bouy' => ['far', 'life-ring'],
185
        'life-buoy' => ['far', 'life-ring'],
186
        'life-saver' => ['far', 'life-ring'],
187
        'lightbulb-o' => ['far', 'lightbulb'],
188
        'line-chart' => ['fas', 'chart-line'],
189
        'linkedin-square' => ['fab', 'linkedin'],
190
        'linkedin' => ['fab', 'linkedin-in'],
191
        'long-arrow-down' => ['fas', 'long-arrow-alt-down'],
192
        'long-arrow-left' => ['fas', 'long-arrow-alt-left'],
193
        'long-arrow-right' => ['fas', 'long-arrow-alt-right'],
194
        'long-arrow-up' => ['fas', 'long-arrow-alt-up'],
195
        'mail-forward' => ['fas', 'share'],
196
        'mail-reply-all' => ['fas', 'reply-all'],
197
        'mail-reply' => ['fas', 'reply'],
198
        'map-marker' => ['fas', 'map-marker-alt'],
199
        'map-o' => ['far', 'map'],
200
        'meanpath' => ['fab', 'font-awesome'],
201
        'meh-o' => ['far', 'meh'],
202
        'minus-square-o' => ['far', 'minus-square'],
203
        'mobile-phone' => ['fas', 'mobile-alt'],
204
        'mobile' => ['fas', 'mobile-alt'],
205
        'money' => ['far', 'money-bill-alt'],
206
        'moon-o' => ['far', 'moon'],
207
        'mortar-board' => ['fas', 'graduation-cap'],
208
        'navicon' => ['fas', 'bars'],
209
        'newspaper-o' => ['far', 'newspaper'],
210
        'paper-plane-o' => ['far', 'paper-plane'],
211
        'paste' => ['far', 'clipboard'],
212
        'pause-circle-o' => ['far', 'pause-circle'],
213
        'pencil-square-o' => ['far', 'edit'],
214
        'pencil-square' => ['fas', 'pen-square'],
215
        'pencil' => ['fas', 'pencil-alt'],
216
        'photo' => ['far', 'image'],
217
        'picture-o' => ['far', 'image'],
218
        'pie-chart' => ['fas', 'chart-pie'],
219
        'play-circle-o' => ['far', 'play-circle'],
220
        'plus-square-o' => ['far', 'plus-square'],
221
        'question-circle-o' => ['far', 'question-circle'],
222
        'ra' => ['fab', 'rebel'],
223
        'refresh' => ['fas', 'sync'],
224
        'remove' => ['fas', 'times'],
225
        'reorder' => ['fas', 'bars'],
226
        'repeat' => ['fas', 'redo'],
227
        'resistance' => ['fab', 'rebel'],
228
        'rmb' => ['fas', 'yen-sign'],
229
        'rotate-left' => ['fas', 'undo'],
230
        'rotate-right' => ['fas', 'redo'],
231
        'rouble' => ['fas', 'ruble-sign'],
232
        'rub' => ['fas', 'ruble-sign'],
233
        'ruble' => ['fas', 'ruble-sign'],
234
        'rupee' => ['fas', 'rupee-sign'],
235
        's15' => ['fas', 'bath'],
236
        'scissors' => ['fas', 'cut'],
237
        'send-o' => ['far', 'paper-plane'],
238
        'send' => ['fas', 'paper-plane'],
239
        'share-square-o' => ['far', 'share-square'],
240
        'shekel' => ['fas', 'shekel-sign'],
241
        'sheqel' => ['fas', 'shekel-sign'],
242
        'shield' => ['fas', 'shield-alt'],
243
        'sign-in' => ['fas', 'sign-in-alt'],
244
        'sign-out' => ['fas', 'sign-out-alt'],
245
        'signing' => ['fas', 'sign-language'],
246
        'sliders' => ['fas', 'sliders-h'],
247
        'smile-o' => ['far', 'smile'],
248
        'snowflake-o' => ['far', 'snowflake'],
249
        'soccer-ball-o' => ['far', 'futbol'],
250
        'sort-alpha-asc' => ['fas', 'sort-alpha-down'],
251
        'sort-alpha-desc' => ['fas', 'sort-alpha-up'],
252
        'sort-amount-asc' => ['fas', 'sort-amount-down'],
253
        'sort-amount-desc' => ['fas', 'sort-amount-up'],
254
        'sort-asc' => ['fas', 'sort-up'],
255
        'sort-desc' => ['fas', 'sort-down'],
256
        'sort-numeric-asc' => ['fas', 'sort-numeric-down'],
257
        'sort-numeric-desc' => ['fas', 'sort-numeric-up'],
258
        'spoon' => ['fas', 'utensil-spoon'],
259
        'square-o' => ['far', 'square'],
260
        'star-half-empty' => ['far', 'star-half'],
261
        'star-half-full' => ['far', 'star-half'],
262
        'star-half-o' => ['far', 'star-half'],
263
        'star-o' => ['far', 'star'],
264
        'sticky-note-o' => ['far', 'sticky-note'],
265
        'stop-circle-o' => ['far', 'stop-circle'],
266
        'sun-o' => ['far', 'sun'],
267
        'support' => ['far', 'life-ring'],
268
        'tablet' => ['fas', 'tablet-alt'],
269
        'tachometer' => ['fas', 'tachometer-alt'],
270
        'television' => ['fas', 'tv'],
271
        'thermometer-0' => ['fas', 'thermometer-empty'],
272
        'thermometer-1' => ['fas', 'thermometer-quarter'],
273
        'thermometer-2' => ['fas', 'thermometer-half'],
274
        'thermometer-3' => ['fas', 'thermometer-three-quarters'],
275
        'thermometer-4' => ['fas', 'thermometer-full'],
276
        'thermometer' => ['fas', 'thermometer-full'],
277
        'thumb-tack' => ['fas', 'thumbtack'],
278
        'thumbs-o-down' => ['far', 'thumbs-down'],
279
        'thumbs-o-up' => ['far', 'thumbs-up'],
280
        'ticket' => ['fas', 'ticket-alt'],
281
        'times-circle-o' => ['far', 'times-circle'],
282
        'times-rectangle-o' => ['far', 'window-close'],
283
        'times-rectangle' => ['fas', 'window-close'],
284
        'toggle-down' => ['far', 'caret-square-down'],
285
        'toggle-left' => ['far', 'caret-square-left'],
286
        'toggle-right' => ['far', 'caret-square-right'],
287
        'toggle-up' => ['far', 'caret-square-up'],
288
        'trash-o' => ['far', 'trash-alt'],
289
        'trash' => ['fas', 'trash-alt'],
290
        'try' => ['fas', 'lira-sign'],
291
        'turkish-lira' => ['fas', 'lira-sign'],
292
        'unsorted' => ['fas', 'sort'],
293
        'usd' => ['fas', 'dollar-sign'],
294
        'user-circle-o' => ['far', 'user-circle'],
295
        'user-o' => ['far', 'user'],
296
        'vcard-o' => ['far', 'address-card'],
297
        'vcard' => ['fas', 'address-card'],
298
        'video-camera' => ['fas', 'video'],
299
        'vimeo' => ['fab', 'vimeo-v'],
300
        'volume-control-phone' => ['fas', 'phone-volume'],
301
        'warning' => ['fas', 'exclamation-triangle'],
302
        'wechat' => ['fab', 'weixin'],
303
        'wheelchair-alt' => ['fab', 'accessible-icon'],
304
        'window-close-o' => ['far', 'window-close'],
305
        'won' => ['fas', 'won-sign'],
306
        'y-combinator-square' => ['fab', 'hacker-news'],
307
        'yc-square' => ['fab', 'hacker-news'],
308
        'yc' => ['fab', 'y-combinator'],
309
        'yen' => ['fas', 'yen-sign'],
310
        'youtube-play' => ['fab', 'youtube'],
311
        'youtube-square' => ['fab', 'youtube']
312
    ];
313
314
    /**
315
     * Regular font weight
316
     *
317
     * @param $name
318
     * @param array $options
319
     * @return component\Icon
320
     * @throws \yii\base\InvalidConfigException
321
     */
322
    public static function regular($name, $options = [])
323
    {
324
        return new component\Icon($name, $options, 'far');
325
    }
326
327
    /**
328
     * Solid font weight
329
     *
330
     * @param $name
331
     * @param array $options
332
     * @return component\Icon
333
     * @throws \yii\base\InvalidConfigException
334
     */
335
    public static function solid($name, $options = [])
336
    {
337
        return new component\Icon($name, $options, 'fas');
338
    }
339
340
    /**
341
     * Light font weight (Pro only)
342
     *
343
     * @param $name
344
     * @param array $options
345
     * @return component\Icon
346
     * @throws \yii\base\InvalidConfigException
347
     */
348
    public static function light($name, $options = [])
349
    {
350
        return new component\Icon($name, $options, 'fal');
351
    }
352
353
    /**
354
     * Brand icon
355
     *
356
     * @param $name
357
     * @param array $options
358
     * @return component\Icon
359
     * @throws \yii\base\InvalidConfigException
360
     */
361
    public static function brand($name, $options = [])
362
    {
363
        return new component\Icon($name, $options, 'fab');
364
    }
365
366
    /**
367
     * Creates an `Icon` component that can be used to FontAwesome html icon
368
     *
369
     * @param string $name
370
     * @param array $options
371
     * @return component\Icon
372
     * @throws \yii\base\InvalidConfigException
373
     */
374
    public static function icon($name, $options = [])
375
    {
376
        $name = strtolower(trim($name));
377
        if (array_key_exists($name, static::$fa4to5mapping)) {
378
            return new component\Icon(static::$fa4to5mapping[$name][1], $options, static::$fa4to5mapping[$name][0]);
379
        } elseif (strpos($name, ' ') !== false) {
380
            list($prefix, $name) = explode(' ', $name);
381
            return new component\Icon($name, $options, $prefix);
382
        }
383
        return static::solid($name, $options);
384
    }
385
386
    /**
387
     * Shortcut for `icon()` method
388
     * @see icon()
389
     *
390
     * @param string $name
391
     * @param array $options
392
     * @return component\Icon
393
     * @throws \yii\base\InvalidConfigException
394
     */
395
    public static function i($name, $options = [])
396
    {
397
        return static::icon($name, $options);
398
    }
399
400
    /**
401
     * Creates an `Stack` component that can be used to FontAwesome html icon
402
     *
403
     * @param array $options
404
     * @return component\Stack
405
     */
406
    public static function stack($options = [])
407
    {
408
        return new component\Stack($options);
409
    }
410
411
    /**
412
     * Shortcut for `stack()` method
413
     * @see stack()
414
     *
415
     * @param array $options
416
     * @return component\Stack
417
     */
418
    public static function s($options = [])
419
    {
420
        return static::stack($options);
421
    }
422
423
    /**
424
     * @param array $options
425
     * @return component\UnorderedList
426
     */
427
    public static function ul($options = [])
428
    {
429
        return new component\UnorderedList($options);
430
    }
431
432
    /**
433
     * Size values
434
     * @see component\Icon::size
435
     */
436
    const SIZE_SMALL = self::SIZE_SM; // Backwards compatibility
437
    const SIZE_LARGE = self::SIZE_LG; // Backwards compatibility
438
    const SIZE_XS = 'xs';
439
    const SIZE_SM = 'sm';
440
    const SIZE_LG = 'lg';
441
    const SIZE_2X = '2x';
442
    const SIZE_3X = '3x';
443
    const SIZE_4X = '4x';
444
    const SIZE_5X = '5x';
445
    const SIZE_6X = '6x';
446
    const SIZE_7X = '7x';
447
    const SIZE_8X = '8x';
448
    const SIZE_9X = '9x';
449
    const SIZE_10X = '10x';
450
451
    /**
452
     * Flip values
453
     * @see component\Icon::flip
454
     */
455
    const FLIP_HORIZONTAL = 'h';
456
    const FLIP_VERTICAL = 'v';
457
}
458