1 | <?php |
||
2 | |||
3 | namespace Tequilarapido\Consolify\Progress; |
||
4 | |||
5 | use Symfony\Component\Console\Output\OutputInterface; |
||
6 | |||
7 | class ProgressHelper |
||
8 | { |
||
9 | public static function newProgressInstance($max, $uid, OutputInterface $output) |
||
10 | { |
||
11 | if (! class_exists($progressClass = config('consolify.progress.concrete_class'))) { |
||
12 | throw new \LogicException("Cannot find progress class [$progressClass]"); |
||
13 | } |
||
14 | |||
15 | $progress = (new $progressClass()) |
||
16 | ->setProgressBar($output->createProgressBar($max)) |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
17 | ->setUid($uid); |
||
18 | |||
19 | // Reset progress |
||
20 | $progress->deletePersisted(); |
||
21 | |||
22 | return $progress; |
||
23 | } |
||
24 | |||
25 | /** @return Progress */ |
||
26 | public static function progressFor($uid) |
||
27 | { |
||
28 | if (! class_exists($progressClass = config('consolify.progress.concrete_class'))) { |
||
29 | throw new \LogicException("Cannot find progress class [$progressClass]"); |
||
30 | } |
||
31 | |||
32 | return (new $progressClass())->setUid($uid); |
||
33 | } |
||
34 | } |
||
35 |