Completed
Push — master ( 65d608...8c23df )
by Andrii
02:07
created

SocialLinks::run()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
ccs 0
cts 12
cp 0
rs 9.2
cc 4
eloc 9
nc 4
nop 0
crap 20
1
<?php
2
3
/*
4
 * Theme Manager for Yii2
5
 *
6
 * @link      https://github.com/hiqdev/yii2-thememanager
7
 * @package   yii2-thememanager
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hiqdev\thememanager\widgets;
13
14
use Yii;
15
use yii\helpers\Html;
16
17
class SocialLinks extends \yii\base\Widget
18
{
19
    public $tag = 'li';
20
21
    public $tagOptions = [];
22
23
    public $links = [];
24
25
    public $icons = [
26
        'github' => 'github-alt',
27
        'email'  => 'envelope',
28
    ];
29
30
    public function run()
31
    {
32
        $out = '';
33
        foreach ($this->links as $name => $value) {
34
            if ($value) {
35
                $icon = isset($this->icons[$name]) ? $this->icons[$name] : $name;
36
                $out .= Html::beginTag($this->tag, $this->tagOptions);
37
                $out .= Html::a(Html::tag('span', '', ['class' => "fa fa-{$icon}"]), $value, ['title' => ucfirst($name)]);
38
                $out .= Html::endTag($this->tag);
39
            }
40
        }
41
42
        return $out;
43
    }
44
}
45