Button::wrapSpan()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Boduch\Grid\Components;
4
5
class Button extends Component
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $url;
11
12
    /**
13
     * @var string
14
     */
15
    protected $text;
16
17
    /**
18
     * @var array
19
     */
20
    protected $attributes = [];
21
22
    /**
23
     * @param string $url
24
     * @param string $text
25
     * @param array $attributes
26
     */
27
    public function __construct($url, $text, array $attributes = [])
28
    {
29
        $this->url = $url;
30
        $this->text = $text;
31
        $this->setDefaultAttributes($attributes);
32
    }
33
34
    /**
35
     * @return \Illuminate\Support\HtmlString
36
     */
37
    public function render()
38
    {
39
        return $this->tag('a', $this->wrapSpan($this->text), $this->attributes);
40
    }
41
42
    /**
43
     * @param string $text
44
     * @return \Illuminate\Support\HtmlString
45
     */
46
    protected function wrapSpan($text)
47
    {
48
        return $this->tag('span', $text);
49
    }
50
51
    /**
52
     * @param array $attributes
53
     */
54
    protected function setDefaultAttributes(array $attributes = [])
55
    {
56
        $this->attributes = array_merge(['class' => 'btn btn-default', 'href' => $this->url], $attributes);
57
    }
58
}
59