1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AppUtils\StyleCollection; |
6
|
|
|
|
7
|
|
|
use AppUtils\Interface_Stringable; |
8
|
|
|
use AppUtils\StyleCollection; |
9
|
|
|
use AppUtils\StyleCollection\StyleBuilder\Flavors\Background; |
10
|
|
|
use AppUtils\StyleCollection\StyleBuilder\Flavors\Background\BackgroundColor; |
11
|
|
|
use AppUtils\StyleCollection\StyleBuilder\Flavors\Color; |
12
|
|
|
use AppUtils\StyleCollection\StyleBuilder\Flavors\Display; |
13
|
|
|
use AppUtils\StyleCollection\StyleBuilder\Flavors\Font; |
14
|
|
|
use AppUtils\StyleCollection\StyleBuilder\Flavors\Height; |
15
|
|
|
use AppUtils\StyleCollection\StyleBuilder\Flavors\Width; |
16
|
|
|
|
17
|
|
|
class StyleBuilder implements Interface_Stringable |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var StyleCollection |
21
|
|
|
*/ |
22
|
|
|
private $collection; |
23
|
|
|
|
24
|
|
|
private function __construct(?StyleCollection $collection=null) |
25
|
|
|
{ |
26
|
|
|
if($collection === null) |
27
|
|
|
{ |
28
|
|
|
$collection = StyleCollection::create(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
$this->collection = $collection; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public static function create(?StyleCollection $collection=null) : StyleBuilder |
35
|
|
|
{ |
36
|
|
|
return new StyleBuilder($collection); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function display() : Display |
40
|
|
|
{ |
41
|
|
|
return new Display($this, $this->collection); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function font() : Font |
45
|
|
|
{ |
46
|
|
|
return new Font($this, $this->collection); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function color() : Color |
50
|
|
|
{ |
51
|
|
|
return new Color($this, $this->collection); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function background() : Background |
55
|
|
|
{ |
56
|
|
|
return new Background($this, $this->collection); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function width() : Width |
60
|
|
|
{ |
61
|
|
|
return new Width($this, $this->collection); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function height() : Height |
65
|
|
|
{ |
66
|
|
|
return new Height($this, $this->collection); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function __toString() |
70
|
|
|
{ |
71
|
|
|
return $this->collection->render(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getCollection() : StyleCollection |
75
|
|
|
{ |
76
|
|
|
return $this->collection; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|