Completed
Push — master ( bd5822...94be6b )
by Revin
03:13
created

Icon::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 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 3
    public function __construct($name, $options = [])
28
    {
29 3
        Html::addCssClass($options, Ion::$cssPrefix . '-' . $name);
30
31 3
        $this->options = $options;
32 3
    }
33
34
    /**
35
     * @return string
36
     */
37 2
    public function __toString()
38
    {
39 2
        return $this->render();
40
    }
41
42
    /**
43
     * @param string $class
44
     * @return self
45
     */
46 1
    public function addCssClass($class)
47
    {
48 1
        Html::addCssClass($this->options, $class);
49
50 1
        return $this;
51
    }
52
53
    /**
54
     * @return string
55
     */
56 2
    public function render()
57
    {
58 2
        return Html::tag('i', null, $this->options);
59
    }
60
}
61