Icon   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 44
ccs 5
cts 6
cp 0.8333
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A render() 0 4 1
A __construct() 0 6 1
A addCssClass() 0 6 1
1
<?php
2
/**
3
 * Icon.php
4
 * @author Revin Roman
5
 * @link https://rmrevin.com
6
 */
7
8
namespace rmrevin\yii\ionicon\component;
9
10
use rmrevin\yii\ionicon\Ion;
11
use yii\helpers\Html;
12
13
/**
14
 * Class Icon
15
 * @package rmrevin\yii\ionicon\component
16
 */
17
class Icon
18
{
19
20
    /** @var array */
21
    private $options = [];
22
23
    /**
24
     * @param string $name
25
     * @param array $options
26
     */
27 1
    public function __construct($name, $options = [])
28
    {
29
        Html::addCssClass($options, Ion::$cssPrefix . '-' . $name);
30
31 1
        $this->options = $options;
32 1
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function __toString()
38
    {
39
        return $this->render();
40
    }
41
42
    /**
43
     * @param string $class
44
     * @return self
45
     */
46 1
    public function addCssClass($class)
47
    {
48
        Html::addCssClass($this->options, $class);
49
50 1
        return $this;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function render()
57
    {
58
        return Html::tag('i', null, $this->options);
59
    }
60
}
61