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

Trait_ClassableViaAttributes   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A removeClass() 0 4 1
A hasClass() 0 3 1
A hasClasses() 0 3 1
A classesToAttribute() 0 3 1
A getClasses() 0 3 1
A addClass() 0 4 1
A classesToString() 0 3 1
A addClasses() 0 4 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