| Total Complexity | 10 |
| Total Lines | 90 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | final class Progress |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * The current progress. |
||
| 15 | * |
||
| 16 | * @var int |
||
| 17 | */ |
||
| 18 | private int $current = 0; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * The total possible progress. |
||
| 22 | * |
||
| 23 | * @var int|null |
||
| 24 | */ |
||
| 25 | private ?int $total = null; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Set the current progress |
||
| 29 | * |
||
| 30 | * @param int $current |
||
| 31 | * @return self |
||
| 32 | */ |
||
| 33 | 2 | public function setCurrent(int $current): self |
|
| 34 | { |
||
| 35 | 2 | $this->current = $current; |
|
| 36 | |||
| 37 | 2 | return $this; |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Retrieve the current progress |
||
| 42 | * |
||
| 43 | * @return int |
||
| 44 | */ |
||
| 45 | 1 | public function current(): int |
|
| 46 | { |
||
| 47 | 1 | return $this->current; |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Set the total possible progress |
||
| 52 | * |
||
| 53 | * @param int|null $total |
||
| 54 | * @return self |
||
| 55 | */ |
||
| 56 | 2 | public function setTotal(?int $total): self |
|
| 57 | { |
||
| 58 | 2 | $this->total ??= $total; |
|
| 59 | |||
| 60 | 2 | return $this; |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Retrieve the total possible progress |
||
| 65 | * |
||
| 66 | * @return int|null |
||
| 67 | */ |
||
| 68 | 1 | public function total(): ?int |
|
| 69 | { |
||
| 70 | 1 | return $this->total; |
|
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Retrieve the formatted percentage of the progress |
||
| 75 | * |
||
| 76 | * @return string|null |
||
| 77 | */ |
||
| 78 | 1 | public function format(): ?string |
|
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Retrieve the percentage of the progress |
||
| 85 | * |
||
| 86 | * @return float|null |
||
| 87 | */ |
||
| 88 | 2 | public function percentage(): ?float |
|
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Retrieve the fraction of the progress |
||
| 95 | * |
||
| 96 | * @return float|null |
||
| 97 | */ |
||
| 98 | 2 | public function fraction(): ?float |
|
| 103 |