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

AuthHelper::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.6666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace BeyondCode\TagHelper\Helpers;
4
5
use BeyondCode\TagHelper\Helper;
6
use BeyondCode\TagHelper\Html\HtmlElement;
7
8 View Code Duplication
class AuthHelper extends Helper
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    protected $targetAttribute = 'auth';
11
12
    public function process(HtmlElement $element)
13
    {
14
        // Check if an explicit attribute value was specified.
15
        if ($element->getAttribute('auth') === true) {
16
            $auth = null;
17
        } else {
18
            $auth = $element->getAttributeForBlade('auth');
19
        }
20
21
        $element->removeAttribute('auth');
22
23
        $outerText = '@auth('.$auth.') ';
24
        $outerText .= $element->getOuterText();
25
        $outerText .= ' @endauth';
26
27
        $element->setOuterText($outerText);
28
29
    }
30
}
31