Completed
Push — master ( 4c6a99...b37e90 )
by Alec
05:15 queued 02:22
created

BenchmarkSimpleProgressBar   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 27
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 25 2
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Tools;
4
5
class BenchmarkSimpleProgressBar extends Benchmark
6
{
7 1
    public function __construct(
8
        int $iterations = 1000,
9
        bool $quiet = false
10
    ) {
11 1
        parent::__construct($iterations);
12 1
        $width = $this->advanceSteps = $this->terminalWidth();
13
        // @codeCoverageIgnoreStart
14
        if (!$quiet) {
15
            $progressStart =
16
                static function () use ($width): void {
17
                    echo ' [' . str_repeat('░', $width) . ']';
18
                    echo "\e[" . ($width + 1) . 'D';
19
                };
20
            $progressAdvance =
21
                static function (): void {
22
                    echo '█';
23
                };
24
25
            $progressFinish =
26
                static function () use ($width): void {
27
                    echo "\e[" . ($width + 1) . 'D';
28
                    echo "\e[K";
29
                };
30
31
            $this->showProgressBy($progressStart, $progressAdvance, $progressFinish);
32
        }
33
        // @codeCoverageIgnoreEnd
34 1
    }
35
}
36