Test Failed
Push — master ( 87b409...65f6df )
by Filippo
21:44 queued 16:15
created

ManagerHelpers::hasProgressBar()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
nc 2
nop 2
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Jobtech\LaravelChunky\Concerns;
4
5
use Symfony\Component\Console\Helper\ProgressBar;
6
use Symfony\Component\Console\Style\OutputStyle;
7
8
trait ManagerHelpers
9
{
10
    /**
11
     * This method checks if the application is running in console and, if output style is not null, it creates a new
12
     * progress bar instance, otherwise returns null.
13
     *
14
     * @param \Symfony\Component\Console\Style\OutputStyle|null $output
15
     * @param int $count
16
     *
17
     * @return \Symfony\Component\Console\Helper\ProgressBar|null
18
     */
19
    public function hasProgressBar(?OutputStyle $output, int $count): ?ProgressBar
20
    {
21
        if ($output !== null && app()->runningInConsole()) {
0 ignored issues
show
introduced by
The method runningInConsole() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

21
        if ($output !== null && app()->/** @scrutinizer ignore-call */ runningInConsole()) {
Loading history...
22
            return $output->createProgressBar($count);
23
        }
24
25
        return null;
26
    }
27
}
28