| Total Complexity | 2 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 5 | class BenchmarkSimpleProgressBar extends Benchmark |
||
| 6 | { |
||
| 7 | /** @var int */ |
||
| 8 | private $progressBarWidth; |
||
| 9 | |||
| 10 | 1 | public function __construct( |
|
| 11 | int $iterations = 1000, |
||
| 12 | ?int $progressBarWidth = null |
||
| 13 | ) { |
||
| 14 | 1 | parent::__construct($iterations); |
|
| 15 | 1 | $this->progressBarWidth = $this->advanceSteps = $progressBarWidth ?? $this->advanceSteps; |
|
| 16 | |||
| 17 | $progressAdvance = |
||
| 18 | function (): void { |
||
| 19 | 1 | echo '*'; |
|
| 20 | 1 | }; |
|
| 21 | |||
| 22 | $progressFinish = |
||
| 23 | function (): void { |
||
| 24 | 1 | echo "\e[" . $this->progressBarWidth . 'D'; |
|
| 25 | 1 | echo "\e[K"; |
|
| 26 | 1 | }; |
|
| 27 | |||
| 28 | 1 | $this->showProgressBy(null, $progressAdvance, $progressFinish); |
|
| 29 | 1 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @return int |
||
| 33 | */ |
||
| 34 | 1 | public function getProgressBarWidth(): int |
|
| 37 | } |
||
| 38 | } |
||
| 39 |