1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
// 15.03.23 |
5
|
|
|
|
6
|
|
|
namespace AlecRabbit\Spinner\Core\Defaults\A; |
7
|
|
|
|
8
|
|
|
use AlecRabbit\Spinner\Contract\IFrame; |
9
|
|
|
use AlecRabbit\Spinner\Core\Defaults\Contract\IDefaults; |
10
|
|
|
use AlecRabbit\Spinner\Core\Defaults\Contract\IWidgetSettings; |
11
|
|
|
use AlecRabbit\Spinner\Core\Factory\FrameFactory; |
12
|
|
|
use AlecRabbit\Spinner\Core\Pattern\Contract\IPattern; |
13
|
|
|
|
14
|
|
|
abstract class AWidgetSettings extends ADefaultsChild implements IWidgetSettings |
15
|
|
|
{ |
16
|
|
|
protected static ?IFrame $leadingSpacer = null; |
17
|
|
|
protected static ?IFrame $trailingSpacer = null; |
18
|
|
|
protected static ?IPattern $charPattern = null; |
19
|
|
|
protected static ?IPattern $stylePattern = null; |
20
|
|
|
private static ?IWidgetSettings $objSettings = null; // private, singleton |
21
|
|
|
|
22
|
|
|
final protected function __construct(IDefaults $parent) |
23
|
|
|
{ |
24
|
|
|
parent::__construct($parent); |
25
|
|
|
$this->reset(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
protected function reset(): void |
29
|
|
|
{ |
30
|
|
|
static::$charPattern = null; |
31
|
|
|
static::$stylePattern = null; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
final public static function getInstance(IDefaults $parent): IWidgetSettings |
35
|
|
|
{ |
36
|
|
|
if (null === self::$objSettings) { |
37
|
|
|
self::$objSettings = |
38
|
|
|
new class ($parent) extends AWidgetSettings { |
39
|
|
|
}; |
40
|
|
|
} |
41
|
|
|
return self::$objSettings; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getLeadingSpacer(): IFrame |
45
|
|
|
{ |
46
|
|
|
if (null === static::$leadingSpacer) { |
47
|
|
|
static::$leadingSpacer = FrameFactory::createEmpty(); |
48
|
|
|
} |
49
|
|
|
return static::$leadingSpacer; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getTrailingSpacer(): IFrame |
53
|
|
|
{ |
54
|
|
|
if (null === static::$trailingSpacer) { |
55
|
|
|
static::$trailingSpacer = FrameFactory::createSpace(); |
56
|
|
|
} |
57
|
|
|
return static::$trailingSpacer; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setLeadingSpacer(IFrame $frame): static |
61
|
|
|
{ |
62
|
|
|
static::$leadingSpacer = $frame; |
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function setTrailingSpacer(IFrame $frame): static |
67
|
|
|
{ |
68
|
|
|
static::$trailingSpacer = $frame; |
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getStylePattern(): ?IPattern |
73
|
|
|
{ |
74
|
|
|
return static::$stylePattern; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getCharPattern(): ?IPattern |
78
|
|
|
{ |
79
|
|
|
return static::$charPattern; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function setStylePattern(IPattern $pattern): static |
83
|
|
|
{ |
84
|
|
|
static::$stylePattern = $pattern; |
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function setCharPattern(IPattern $pattern): static |
89
|
|
|
{ |
90
|
|
|
static::$charPattern = $pattern; |
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|