ProgressHelper::progressFor()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 3
c 2
b 1
f 0
nc 2
nop 1
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 6
rs 10
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
The method createProgressBar() does not exist on Symfony\Component\Console\Output\OutputInterface. It seems like you code against a sub-type of Symfony\Component\Console\Output\OutputInterface such as Symfony\Component\Console\Style\OutputStyle. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
            ->setProgressBar($output->/** @scrutinizer ignore-call */ createProgressBar($max))
Loading history...
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