Passed
Push — master ( 823aee...b9b37f )
by Alec
13:15 queued 12s
created

ADriverSettings::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
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\Core\Defaults\Contract\IDefaults;
9
use AlecRabbit\Spinner\Core\Defaults\Contract\IDriverSettings;
10
use AlecRabbit\Spinner\Core\Defaults\Mixin\DefaultsConst;
11
12
abstract class ADriverSettings extends ADefaultsChild implements IDriverSettings
13
{
14
    use DefaultsConst;
15
16
    protected static string $messageOnFinalize;
17
    protected static string $messageOnExit;
18
    protected static string $messageOnInterrupt;
19
20
    private static ?IDriverSettings $objInstance = null;
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::$messageOnFinalize = static::MESSAGE_ON_FINALIZE;
0 ignored issues
show
Bug introduced by
The constant AlecRabbit\Spinner\Core\...gs::MESSAGE_ON_FINALIZE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
31
        static::$messageOnExit = static::MESSAGE_ON_EXIT;
0 ignored issues
show
Bug introduced by
The constant AlecRabbit\Spinner\Core\...ttings::MESSAGE_ON_EXIT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
32
        static::$messageOnInterrupt = static::MESSAGE_ON_INTERRUPT;
0 ignored issues
show
Bug introduced by
The constant AlecRabbit\Spinner\Core\...s::MESSAGE_ON_INTERRUPT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
33
    }
34
35
    final public static function getInstance(IDefaults $parent): IDriverSettings
36
    {
37
        if (null === self::$objInstance) {
38
            self::$objInstance =
39
                new class ($parent) extends ADriverSettings {
40
                };
41
        }
42
        return self::$objInstance;
43
    }
44
45
    public function getInterruptMessage(): string
46
    {
47
        return static::$messageOnInterrupt;
48
    }
49
50
    public function getFinalMessage(): string
51
    {
52
        return static::$messageOnFinalize;
53
    }
54
55
    public function setFinalMessage(string $finalMessage): static
56
    {
57
        static::$messageOnFinalize = $finalMessage;
58
        return $this;
59
    }
60
61
    public function setInterruptMessage(string $interruptMessage): static
62
    {
63
        static::$messageOnInterrupt = $interruptMessage;
64
        return $this;
65
    }
66
}
67