Completed
Push — develop ( f5c859...666980 )
by Alec
02:44
created

BenchmarkWithSpinner   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 28
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 26 2
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Tools;
4
5
use AlecRabbit\Tools\Spinner\Contracts\SpinnerInterface;
6
use AlecRabbit\Tools\Spinner\SnakeSpinner;
7
8
class BenchmarkWithSpinner extends Benchmark
9
{
10
    public function __construct(
11
        int $iterations = 1000,
12
        bool $quiet = false,
13
        SpinnerInterface $spinner = null
14
    ) {
15
        parent::__construct($iterations);
16
        $this->advanceSteps = $this->terminalWidth();
17
        // @codeCoverageIgnoreStart
18
        if (!$quiet) {
19
            $s = $spinner ?? new SnakeSpinner('Benchmarking');
20
            $progressStart =
21
                static function () use ($s): void {
22
                    echo $s->begin();
23
                };
24
25
            $progressAdvance =
26
                static function () use ($s): void {
27
                    echo $s->spin();
28
                };
29
30
            $progressFinish =
31
                static function () use ($s): void {
32
                    echo $s->end();
33
                };
34
35
            $this->showProgressBy($progressStart, $progressAdvance, $progressFinish);
36
        }
37
        // @codeCoverageIgnoreEnd
38
    }
39
}
40