WidgetBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 32
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A withWidgetRevolver() 0 5 1
A withTrailingSpacer() 0 5 1
A withLeadingSpacer() 0 5 1
A build() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Spinner\Core\Widget\Builder;
6
7
use AlecRabbit\Spinner\Contract\IFrame;
8
use AlecRabbit\Spinner\Core\Widget\Builder\A\AWidgetBuilder;
9
use AlecRabbit\Spinner\Core\Widget\Contract\IWidget;
10
use AlecRabbit\Spinner\Core\Widget\Contract\IWidgetBuilder;
11
use AlecRabbit\Spinner\Core\Widget\Contract\IWidgetRevolver;
12
use AlecRabbit\Spinner\Core\Widget\Widget;
13
14
/**
15
 * @psalm-suppress PossiblyNullArgument
16
 */
17
final class WidgetBuilder extends AWidgetBuilder implements IWidgetBuilder
18
{
19
    public function build(): IWidget
20
    {
21
        $this->validate();
22
23
        return new Widget(
24
            $this->revolver,
0 ignored issues
show
Bug introduced by
It seems like $this->revolver can also be of type null; however, parameter $widgetRevolver of AlecRabbit\Spinner\Core\...t\Widget::__construct() does only seem to accept AlecRabbit\Spinner\Core\...ontract\IWidgetRevolver, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

24
            /** @scrutinizer ignore-type */ $this->revolver,
Loading history...
25
            $this->leadingSpacer,
0 ignored issues
show
Bug introduced by
It seems like $this->leadingSpacer can also be of type null; however, parameter $leadingSpacer of AlecRabbit\Spinner\Core\...t\Widget::__construct() does only seem to accept AlecRabbit\Spinner\Contract\IFrame, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
            /** @scrutinizer ignore-type */ $this->leadingSpacer,
Loading history...
26
            $this->trailingSpacer,
0 ignored issues
show
Bug introduced by
It seems like $this->trailingSpacer can also be of type null; however, parameter $trailingSpacer of AlecRabbit\Spinner\Core\...t\Widget::__construct() does only seem to accept AlecRabbit\Spinner\Contract\IFrame, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
            /** @scrutinizer ignore-type */ $this->trailingSpacer,
Loading history...
27
        );
28
    }
29
30
    public function withWidgetRevolver(IWidgetRevolver $revolver): IWidgetBuilder
31
    {
32
        $clone = clone $this;
33
        $clone->revolver = $revolver;
34
        return $clone;
35
    }
36
37
    public function withLeadingSpacer(IFrame $leadingSpacer): IWidgetBuilder
38
    {
39
        $clone = clone $this;
40
        $clone->leadingSpacer = $leadingSpacer;
41
        return $clone;
42
    }
43
44
    public function withTrailingSpacer(IFrame $trailingSpacer): IWidgetBuilder
45
    {
46
        $clone = clone $this;
47
        $clone->trailingSpacer = $trailingSpacer;
48
        return $clone;
49
    }
50
}
51