Completed
Push — master ( 6ec6b5...364731 )
by Adam
02:30
created

Button::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 6
rs 9.4285
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('button', $this->text, $this->attributes);
40
    }
41
42
    /**
43
     * @param array $attributes
44
     */
45
    protected function setDefaultAttributes(array $attributes = [])
46
    {
47
        $this->attributes = array_merge(['class' => 'btn btn-default'], $attributes);
48
    }
49
}
50