Passed
Push — master ( 689ec5...45f08c )
by Sebastian
05:26
created

Traits_Attributable   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 12
c 1
b 0
f 0
dl 0
loc 62
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A attr() 0 4 1
A removeAttribute() 0 4 1
A attrQuotes() 0 4 1
A prop() 0 4 1
A hasAttributes() 0 3 1
A attrURL() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils;
6
7
trait Traits_Attributable
8
{
9
    abstract public function getAttributes() : AttributeCollection;
10
11
    public function hasAttributes() : bool
12
    {
13
        return $this->getAttributes()->hasAttributes();
14
    }
15
16
    /**
17
     * @param string $name
18
     * @param string|number|bool|Interface_Stringable|StringBuilder_Interface|NULL $value
19
     * @return $this
20
     */
21
    public function attr(string $name, $value)
22
    {
23
        $this->getAttributes()->attr($name, $value);
24
        return $this;
25
    }
26
27
    /**
28
     * @param string $name
29
     * @param string $value
30
     * @return $this
31
     */
32
    public function attrURL(string $name, string $value)
33
    {
34
        $this->getAttributes()->attrURL($name, $value);
35
        return $this;
36
    }
37
38
    /**
39
     * @param string $name
40
     * @param string|number|bool|Interface_Stringable|StringBuilder_Interface|NULL $value
41
     * @return $this
42
     */
43
    public function attrQuotes(string $name, $value)
44
    {
45
        $this->getAttributes()->attrQuotes($name, $value);
46
        return $this;
47
    }
48
49
50
    /**
51
     * @param string $name
52
     * @param bool $enabled
53
     * @return $this
54
     */
55
    public function prop(string $name, bool $enabled=true)
56
    {
57
        $this->getAttributes()->prop($name, $enabled);
58
        return $this;
59
    }
60
61
    /**
62
     * @param string $name
63
     * @return $this
64
     */
65
    public function removeAttribute(string $name)
66
    {
67
        $this->getAttributes()->remove($name);
68
        return $this;
69
    }
70
}
71