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

ALoopSettings   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 51
rs 10
wmc 6

12 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ overrideAutoStartOption() 0 4 1
A reset() 0 4 1
overrideSignalHandlersOption() 0 4 ?
getSignalHandlersOption() 0 3 ?
A hp$0 ➔ getSignalHandlersOption() 0 3 1
getAutoStartOption() 0 3 ?
A __construct() 0 4 1
A hp$0 ➔ overrideSignalHandlersOption() 0 4 1
A hp$0 ➔ getInstance() 0 8 2
overrideAutoStartOption() 0 4 ?
A hp$0 ➔ getAutoStartOption() 0 3 1
getInstance() 0 8 ?
1
<?php
2
3
declare(strict_types=1);
4
// 20.03.23
5
namespace AlecRabbit\Spinner\Core\Defaults\A;
6
7
use AlecRabbit\Spinner\Contract\AutoStart;
8
use AlecRabbit\Spinner\Contract\SignalHandlers;
9
use AlecRabbit\Spinner\Core\Defaults\Contract\IDefaults;
10
use AlecRabbit\Spinner\Core\Defaults\Contract\ILoopSettings;
11
use AlecRabbit\Spinner\Core\Defaults\Mixin\DefaultsConst;
12
13
abstract class ALoopSettings extends ADefaultsChild implements ILoopSettings
14
{
15
    use DefaultsConst;
16
17
    protected static AutoStart $autoStartOption;
18
    protected static SignalHandlers $signalHandlersOption;
19
20
    private static ?ILoopSettings $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::$autoStartOption = static::AUTO_START_OPTION;
0 ignored issues
show
Bug introduced by
The constant AlecRabbit\Spinner\Core\...ings::AUTO_START_OPTION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
31
        static::$signalHandlersOption = static::SIGNAL_HANDLERS_OPTION;
0 ignored issues
show
Bug introduced by
The constant AlecRabbit\Spinner\Core\...:SIGNAL_HANDLERS_OPTION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
32
    }
33
34
    final public static function getInstance(IDefaults $parent): ILoopSettings
35
    {
36
        if (null === self::$objInstance) {
37
            self::$objInstance =
38
                new class ($parent) extends ALoopSettings {
39
                };
40
        }
41
        return self::$objInstance;
42
    }
43
44
    public function getAutoStartOption(): AutoStart
45
    {
46
        return static::$autoStartOption;
47
    }
48
49
    public function getSignalHandlersOption(): SignalHandlers
50
    {
51
        return static::$signalHandlersOption;
52
    }
53
54
    public function overrideAutoStartOption(AutoStart $autoStartOption): ILoopSettings
55
    {
56
        static::$autoStartOption = $autoStartOption;
57
        return $this;
58
    }
59
60
    public function overrideSignalHandlersOption(SignalHandlers $signalHandlersOption): ILoopSettings
61
    {
62
        static::$signalHandlersOption = $signalHandlersOption;
63
        return $this;
64
    }
65
}