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

SocialLinks   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 28
ccs 0
cts 13
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 14 4
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