Lines
50.00%
1 / 2
Functions and Methods
50.00%
1 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Progress | 50.00% | 1 / 2 | 50.00% | 1 / 2 | 2.50 | 0.00% | 0 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| ratio | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Lorekeeper\Client\Script; | |
| 6 | ||
| 7 | final readonly class Progress implements Instruction | |
| 8 | { | |
| 9 | /** | |
| 10 | * @param non-negative-int $done | |
| 11 | * @param positive-int $total | |
| 12 | */ | |
| 13 | public function __construct( | |
| 14 | public int $done, | |
| 15 | public int $total, | |
| 16 | ) {} | |
| 17 | ||
| 18 | public function ratio(): float | |
| 19 | { | |
| 20 | return min(1.0, $this->done / $this->total); | |
| 21 | } | |
| 22 | } |