Passed
Push — master ( de3d61...be839c )
by Alec
13:42 queued 13s
created

DriverSetup::enableInitialization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
6
namespace AlecRabbit\Spinner\Core;
7
8
use AlecRabbit\Spinner\Core\Contract\IDriver;
9
use AlecRabbit\Spinner\Core\Contract\IDriverLinker;
10
use AlecRabbit\Spinner\Core\Contract\IDriverSetup;
11
12
final class DriverSetup implements IDriverSetup
13
{
14
    private bool $initializationEnabled = false;
15
    private bool $linkerEnabled = false;
16
17
    public function __construct(
18
        protected IDriverLinker $linker,
19
    ) {
20
    }
21
22
    public function setup(IDriver $driver): void
23
    {
24
        if ($this->initializationEnabled) {
25
            $driver->initialize();
26
        }
27
28
        if ($this->linkerEnabled) {
29
            $this->linker->link($driver);
30
        }
31
    }
32
33
    public function enableInitialization(bool $enable): IDriverSetup
34
    {
35
        $this->initializationEnabled = $enable;
36
        return $this;
37
    }
38
39
    public function enableLinker(bool $enable): IDriverSetup
40
    {
41
        $this->linkerEnabled = $enable;
42
        return $this;
43
    }
44
}
45