Passed
Push — master ( 74eb68...ffff93 )
by Chris
13:55
created

AbstractHtmlAttribute::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace WebTheory\Html\Attributes;
4
5
use WebTheory\Html\Contracts\HtmlAttributeInterface;
6
7
abstract class AbstractHtmlAttribute implements HtmlAttributeInterface
8
{
9
    /**
10
     *
11
     */
12
    protected $attribute;
13
14
    protected const ATTRIBUTE = null;
15
16
    /**
17
     *
18
     */
19
    public function __toString()
20
    {
21
        return $this->getAttrStr();
22
    }
23
24
    /**
25
     *
26
     */
27
    public function getAttrStr(): string
28
    {
29
        $attr = $this::ATTRIBUTE ?? $this->attrubute;
30
        $val = $this->parse();
31
32
        return "{$attr}=\"{$val}\"";
33
    }
34
}
35