ProgressHelper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 11
c 2
b 1
f 0
dl 0
loc 26
ccs 0
cts 17
cp 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A progressFor() 0 7 2
A newProgressInstance() 0 14 2
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