Passed
Push — master ( eb7214...99cc8c )
by Alec
02:56 queued 10s
created

FrameJuggler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Spinner\Core\Jugglers;
4
5
use AlecRabbit\Accessories\Circular;
6
use AlecRabbit\Spinner\Core\Calculator;
7
use AlecRabbit\Spinner\Core\Coloring\Style;
8
use AlecRabbit\Spinner\Core\Sentinel;
9
use AlecRabbit\Spinner\Settings\Settings;
10
11
class FrameJuggler extends AbstractJuggler
12
{
13
    /** @var Circular */
14
    protected $frames;
15
16 20
    public function __construct(Settings $settings, Style $style)
17
    {
18 20
        $frames = $settings->getFrames();
19 20
        Sentinel::assertFrames($frames);
20 20
        $this->frames = new Circular($frames);
21 20
        $this->init($style);
22 20
        $this->currentFrameErasingLength =
23 20
            Calculator::computeErasingLength($frames) + strlen($this->spacer) + $this->formatErasingShift;
24 20
    }
25
26
    /**
27
     * @return string
28
     */
29 19
    protected function getCurrentFrame(): string
30
    {
31 19
        return $this->frames->value();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->frames->value() could return the type AlecRabbit\Accessories\Rewindable which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
32
    }
33
}
34