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

StyleContainer::setStylePX()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils\StyleCollection\StyleBuilder;
6
7
use AppUtils\StyleCollection;
8
use AppUtils\StyleCollection\StyleBuilder;
9
10
abstract class StyleContainer
11
{
12
    /**
13
     * @var StyleBuilder
14
     */
15
    protected $styles;
16
17
    /**
18
     * @var StyleCollection
19
     */
20
    protected $collection;
21
22
    /**
23
     * @var string
24
     */
25
    protected $name;
26
27
    public function __construct(StyleBuilder $styles, StyleCollection $collection)
28
    {
29
        $this->styles = $styles;
30
        $this->collection = $collection;
31
        $this->name = $this->getName();
32
    }
33
34
    abstract protected function getName() : string;
35
36
    final protected function setStyle(string $value, bool $important) : StyleBuilder
37
    {
38
        $this->collection->style($this->name, $value, $important);
39
        return $this->styles;
40
    }
41
42
    final protected function setStylePX(int $value, bool $important) : StyleBuilder
43
    {
44
        $this->collection->stylePX($this->name, $value, $important);
45
        return $this->styles;
46
    }
47
48
    final protected function setStylePercent(float $value, bool $important) : StyleBuilder
49
    {
50
        $this->collection->stylePercent($this->name, $value, $important);
51
        return $this->styles;
52
    }
53
54
    final protected function setStyleEM(float $value, bool $important) : StyleBuilder
55
    {
56
        $this->collection->styleEM($this->name, $value, $important);
57
        return $this->styles;
58
    }
59
60
    final protected function setStyleREM(float $value, bool $important) : StyleBuilder
61
    {
62
        $this->collection->styleREM($this->name, $value, $important);
63
        return $this->styles;
64
    }
65
}
66