Completed
Push — master ( 27e495...3c3313 )
by Edson
02:31
created

Buttons::btnCustom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
ccs 2
cts 3
cp 0.6667
crap 1.037
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sketch\Tpl\Tag;
4
5
class Buttons extends Tag
6
{
7 2
    public function __construct()
8
    {
9 2
        $this->btnDefault();
10 2
        $this->btnCustom();
11 2
    }
12
13 2
    private function btnDefault()
14
    {
15 2
        $regex = "/{(\s?)+btn(\s?)+}(.*?){(\s?)+\/btn(\s?)+}/is";
16
17
        Tag::match($regex, function($value = "") {
18
19
            Tag::replace("<button class=\"btn\">$value</button>");
20 2
        });
21 2
    }
22
23 2
    private function btnCustom()
24
    {
25 2
        $regex = "/{(\s?)+btn(\s?)+[\"'](.*?)[\"'](\s?)+}(.*?){(\s?)+\/btn(\s?)+}/is";
26
27
        Tag::match($regex, function($class = "", $value = "") {
28
29
            Tag::replace("<button class=\"btn btn-$class\">$value</button>");
30 2
        });
31 2
    }
32
}
33