LiveCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 37
ccs 7
cts 10
cp 0.7
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 16 4
1
<?php
2
3
namespace NFLScores\Commands;
4
5
use ErrorException;
6
use NFLScores\Utilities\Printer;
7
8
class LiveCommand extends AbstractCommand
9
{
10
    /**
11
     * The signature of the command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'live {team?}';
16
17
    /**
18
     * The description of the command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Show the current live games';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return void
28
     */
29 3
    public function handle(): void
30
    {
31
        try {
32 3
            $games = (!is_null($this->argument('team')))
33 2
                ? $this->NFL->getLiveGameByTeam($this->argument('team'))
0 ignored issues
show
Bug introduced by
It seems like $this->argument('team') can also be of type null and string[]; however, parameter $team of NFLScores\Models\NFL::getLiveGameByTeam() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

33
                ? $this->NFL->getLiveGameByTeam(/** @scrutinizer ignore-type */ $this->argument('team'))
Loading history...
34 3
                : $this->NFL->getLiveGames();
35
36 3
            if (is_null($games)) {
37
                exit($this->line('Sorry, there is no live games at this moment.'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->line('Sorry, ther...games at this moment.') targeting Illuminate\Console\Command::line() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
38
            }
39
40 3
            $printer = new Printer($this);
41
42 3
            $printer->renderScoreBoard($games);
43
        } catch (ErrorException $e) {
44
            exit($this->line('Sorry, there was a problem fetching the remote data.'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->line('Sorry, ther...hing the remote data.') targeting Illuminate\Console\Command::line() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
45
        }
46 3
    }
47
}
48