Total Complexity | 5 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | trait HasProgressListener |
||
9 | { |
||
10 | /** |
||
11 | * @var \Closure |
||
12 | */ |
||
13 | protected $onProgressCallback; |
||
14 | |||
15 | /** |
||
16 | * @var float |
||
17 | */ |
||
18 | protected $lastPercentage; |
||
19 | |||
20 | /** |
||
21 | * @var float |
||
22 | */ |
||
23 | protected $lastRemaining = 0; |
||
24 | |||
25 | /** |
||
26 | * Setter for the callback. |
||
27 | * |
||
28 | * @param Closure $callback |
||
29 | * @return self |
||
30 | */ |
||
31 | public function onProgress(Closure $callback): self |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Only calls the callback if the percentage is below 100 and is different |
||
40 | * from the previous emitted percentage. |
||
41 | * |
||
42 | * @param \Evenement\EventEmitterInterface $format |
||
43 | * @return void |
||
44 | */ |
||
45 | private function applyProgressListenerToFormat(EventEmitterInterface $format) |
||
59 |