Completed
Push — master ( 3ec9c1...244937 )
by Max
02:44
created

WeekCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 29
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 2
1
<?php
2
3
namespace NFLScores\Commands;
4
5
use ErrorException;
6
use NFLScores\Utilities\Printer;
7
8
class WeekCommand extends AbstractCommand
9
{
10
    /**
11
     * The signature of the command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'week';
16
17
    /**
18
     * The description of the command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Show the scheduled games for the week';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return void
28
     */
29 1
    public function handle(): void
30
    {
31
        try {
32 1
            $printer = new Printer($this);
33
34 1
            $printer->renderGamesList($this->NFL->getWeekGames());
35
        } catch (ErrorException $e) {
36
            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...
37
        }
38 1
    }
39
}
40