Completed
Push — master ( d1c7cc...233b03 )
by Marcel
01:43
created

ConditionHelper::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace BeyondCode\TagHelper\Helpers;
4
5
use BeyondCode\TagHelper\Helper;
6
use BeyondCode\TagHelper\Html\HtmlElement;
7
8
class ConditionHelper extends Helper
9
{
10
    protected $targetAttribute = 'if';
11
12
    public function process(HtmlElement $element)
13
    {
14
        $condition = $element->getAttribute('if');
15
16
        $element->removeAttribute('if');
17
18
        $outerText = '@if('.$condition.') ';
19
        $outerText .= $element->getOuterText();
20
        $outerText .= ' @endif';
21
22
        $element->setOuterText($outerText);
23
24
    }
25
}
26