Completed
Push — master ( 652e57...3ec9c1 )
by Max
03:33
created

WeekCommand::handle()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 3
nop 0
dl 0
loc 10
ccs 0
cts 6
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NFLScores\Commands;
4
5
use DateTime;
6
use DateTimeZone;
7
use ErrorException;
8
use LaravelZero\Framework\Commands\Command;
9
use NFLScores\Http\NFLHttpClient;
10
use NFLScores\Models\NFL;
11
use NFLScores\Utilities\Printer;
12
13
class WeekCommand extends Command
14
{
15
    /**
16
     * The signature of the command.
17
     *
18
     * @var string
19
     */
20
    protected $signature = 'week';
21
22
    /**
23
     * The description of the command.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Show the scheduled games for the week';
28
29
    /**
30
     * Execute the console command.
31
     *
32
     * @return void
33
     */
34
    public function handle(): void
35
    {
36
        $nfl = new NFL(new NFLHttpClient(), new DateTime('now', new DateTimeZone('US/Eastern')));
37
38
        try {
39
            $printer = new Printer($this);
40
41
            $printer->renderGamesList($nfl->getWeekGames());
42
        } catch (ErrorException $e) {
43
            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...
44
        }
45
    }
46
}
47