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

Traits_Stylable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A removeStyle() 0 4 1
A style() 0 4 1
A styleAuto() 0 4 1
A hasStyles() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils;
6
7
trait Traits_Stylable
8
{
9
    abstract public function getStyles() : StyleCollection;
10
11
    public function hasStyles() : bool
12
    {
13
        return $this->getStyles()->hasStyles();
14
    }
15
16
    /**
17
     * @param string $name
18
     * @param string $value
19
     * @param bool $important
20
     * @return $this
21
     */
22
    public function style(string $name, string $value, bool $important)
23
    {
24
        $this->getStyles()->style($name, $value, $important);
25
        return $this;
26
    }
27
28
    /**
29
     * @param string $name
30
     * @param string|number|NumberInfo|Interface_Stringable|NULL $value
31
     * @param bool $important
32
     * @return $this
33
     */
34
    public function styleAuto(string $name, $value, bool $important)
35
    {
36
        $this->getStyles()->styleAuto($name, $value, $important);
37
        return $this;
38
    }
39
40
    /**
41
     * @param string $name
42
     * @return $this
43
     */
44
    public function removeStyle(string $name)
45
    {
46
        $this->getStyles()->remove($name);
47
        return $this;
48
    }
49
}
50