SocialLinks   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 14 4
1
<?php
2
/**
3
 * Pluggable themes for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-thememanager
6
 * @package   yii2-thememanager
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\thememanager\widgets;
12
13
use yii\helpers\Html;
14
15
/**
16
 * SocialLinks widget.
17
 * @author Andrii Vasyliev <[email protected]>
18
 */
19
class SocialLinks extends \yii\base\Widget
20
{
21
    public $tag = 'li';
22
23
    public $tagOptions = [];
24
25
    public $links = [];
26
27
    public $linkOptions = [];
28
29
    public $icons = [
30
        'github' => 'github-alt',
31
        'email'  => 'envelope',
32
    ];
33
34
    public function run()
35
    {
36
        $out = '';
37
        foreach ($this->links as $name => $value) {
38
            if ($value) {
39
                $icon = isset($this->icons[$name]) ? $this->icons[$name] : $name;
40
                $out .= Html::beginTag($this->tag, $this->tagOptions);
41
                $out .= Html::a(Html::tag('span', '', ['class' => "fa fa-{$icon}"]), $value, array_merge(['title' => ucfirst($name)], $this->linkOptions));
42
                $out .= Html::endTag($this->tag);
43
            }
44
        }
45
46
        return $out;
47
    }
48
}
49