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

Trait_ClassableViaAttributes::addClasses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils;
6
7
trait Trait_ClassableViaAttributes
8
{
9
    abstract public function getAttributes() : AttributeCollection;
10
11
    public function addClass(string $name) : HTMLTag
12
    {
13
        $this->getAttributes()->addClass($name);
14
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type AppUtils\Trait_ClassableViaAttributes which includes types incompatible with the type-hinted return AppUtils\HTMLTag.
Loading history...
15
    }
16
17
    public function addClasses(array $names) : HTMLTag
18
    {
19
        $this->getAttributes()->addClasses($names);
20
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type AppUtils\Trait_ClassableViaAttributes which includes types incompatible with the type-hinted return AppUtils\HTMLTag.
Loading history...
21
    }
22
23
    public function hasClass(string $name) : bool
24
    {
25
        return $this->getAttributes()->hasClass($name);
26
    }
27
28
    public function removeClass(string $name) : HTMLTag
29
    {
30
        $this->getAttributes()->removeClass($name);
31
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type AppUtils\Trait_ClassableViaAttributes which includes types incompatible with the type-hinted return AppUtils\HTMLTag.
Loading history...
32
    }
33
34
    public function getClasses() : array
35
    {
36
        return $this->getAttributes()->getClasses();
37
    }
38
39
    public function classesToString() : string
40
    {
41
        return $this->getAttributes()->classesToString();
42
    }
43
44
    public function classesToAttribute() : string
45
    {
46
        return $this->getAttributes()->classesToAttribute();
47
    }
48
49
    public function hasClasses() : bool
50
    {
51
        return $this->getAttributes()->hasClasses();
52
    }
53
}
54