CheckPingLastUpdate::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 3
eloc 10
nc 3
nop 0
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Ping;
6
use Illuminate\Console\Command;
7
8
class CheckPingLastUpdate extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'pings:update-overdue';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Command description';
23
24
    /**
25
     * Create a new command instance.
26
     */
27
    public function __construct()
28
    {
29
        parent::__construct();
30
    }
31
32
    /**
33
     * Execute the console command.
34
     *
35
     * @return mixed
36
     */
37
    public function handle()
38
    {
39
        $results = [];
40
41
        $pings = Ping::active()->get();
0 ignored issues
show
Bug introduced by
The method active() does not exist on App\Ping. Did you maybe mean scopeActive()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
42
        foreach ($pings as $ping) {
43
            /** @var Ping $ping */
44
45
            $results[] = [$ping->error, $ping->name, $ping->last_ping, $ping->frequency_value . ' ' . $ping->frequency, $ping->overdueDate, $ping->overdue];
46
47
            if ($ping->overdue) {
48
                $ping->setError();
49
            } else {
50
                $ping->clearError();
51
            }
52
53
        }
54
55
        $this->table(['error', 'name', 'last_ping', 'frequency', 'overdue_date', 'overdue'], $results);
56
    }
57
}
58