TodayCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 35
ccs 5
cts 8
cp 0.625
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 14 3
1
<?php
2
3
namespace NFLScores\Commands;
4
5
use ErrorException;
6
use NFLScores\Utilities\Printer;
7
8
class TodayCommand extends AbstractCommand
9
{
10
    /**
11
     * The signature of the command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'today';
16
17
    /**
18
     * The description of the command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Show the scheduled games for today';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return void
28
     */
29 1
    public function handle(): void
30
    {
31
        try {
32 1
            $todayGames = $this->NFL->getTodayGames();
33
34 1
            if (is_null($todayGames)) {
35
                exit($this->line('Sorry, there is no games scheduled for today.'));
0 ignored issues
show
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...
Bug introduced by
Are you sure the usage of $this->line('Sorry, ther... scheduled for today.') 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...
36
            }
37
38 1
            $printer = new Printer($this);
39
40 1
            $printer->renderGamesList($todayGames);
41
        } catch (ErrorException $e) {
42
            exit($this->line('Sorry, there was a problem fetching the remote data.'));
0 ignored issues
show
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...
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...
43
        }
44 1
    }
45
}
46