Passed
Push — master ( 4a1742...ff2740 )
by Alec
03:07 queued 34s
created

AFacade::getSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Spinner\Root\A;
6
7
use AlecRabbit\Spinner\Container\A\AContainerEnclosure;
0 ignored issues
show
Bug introduced by
The type AlecRabbit\Spinner\Container\A\AContainerEnclosure was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use AlecRabbit\Spinner\Core\Contract\IDriver;
9
use AlecRabbit\Spinner\Core\Contract\IDriverProvider;
10
use AlecRabbit\Spinner\Core\Contract\ISpinner;
11
use AlecRabbit\Spinner\Core\Factory\Contract\ISpinnerFactory;
12
use AlecRabbit\Spinner\Core\Loop\Contract\ILoop;
13
use AlecRabbit\Spinner\Core\Loop\Contract\ILoopProvider;
14
use AlecRabbit\Spinner\Core\Settings\Contract\ISettings;
15
use AlecRabbit\Spinner\Core\Settings\Contract\ISettingsProvider;
16
use AlecRabbit\Spinner\Core\Settings\Contract\ISpinnerSettings;
17
use AlecRabbit\Spinner\Exception\DomainException;
18
19
abstract class AFacade extends AContainerEnclosure
20
{
21
    public static function getLoop(): ILoop
22
    {
23
        $loopProvider = self::getLoopProvider();
24
25
        if ($loopProvider->hasLoop()) {
26
            return $loopProvider->getLoop();
27
        }
28
29
        throw new DomainException('Event loop is unavailable.');
30
    }
31
32
    protected static function getLoopProvider(): ILoopProvider
33
    {
34
        return self::getContainer()->get(ILoopProvider::class);
35
    }
36
37
    public static function createSpinner(?ISpinnerSettings $spinnerSettings = null): ISpinner
38
    {
39
        $spinner = self::getSpinnerFactory()->create($spinnerSettings);
40
41
        if ($spinnerSettings?->isAutoAttach() ?? true) {
42
            self::getDriver()->add($spinner);
43
        }
44
45
        return $spinner;
46
    }
47
48
    protected static function getSpinnerFactory(): ISpinnerFactory
49
    {
50
        return self::getContainer()->get(ISpinnerFactory::class);
51
    }
52
53
    public static function getDriver(): IDriver
54
    {
55
        return self::getDriverProvider()->getDriver();
56
    }
57
58
    protected static function getDriverProvider(): IDriverProvider
59
    {
60
        return self::getContainer()->get(IDriverProvider::class);
61
    }
62
63
    public static function getSettings(): ISettings
64
    {
65
        return self::getSettingsProvider()->getUserSettings();
66
    }
67
68
    protected static function getSettingsProvider(): ISettingsProvider
69
    {
70
        return self::getContainer()->get(ISettingsProvider::class);
71
    }
72
}
73