Completed
Push — master ( 1f7728...04afa3 )
by Freek
01:57
created

CheckPresenter::getNextRunDiffAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Spatie\ServerMonitor\Models\Presenters;
4
5
use Carbon\Carbon;
6
use Spatie\ServerMonitor\Helpers\Emoji;
7
use Spatie\ServerMonitor\Models\Enums\CheckStatus;
8
9
trait CheckPresenter
10
{
11
    public function getStatusAsEmojiAttribute(): string
12
    {
13
        if ($this->status === CheckStatus::SUCCESS) {
0 ignored issues
show
Bug introduced by
The property status does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
14
            return Emoji::ok();
15
        }
16
17
        if ($this->status === CheckStatus::FAILED) {
18
            return Emoji::notOk();
19
        }
20
21
        if ($this->status === CheckStatus::WARNING) {
22
            return Emoji::warning();
23
        }
24
25
        if ($this->status === CheckStatus::NOT_YET_CHECKED) {
26
            return Emoji::unknown();
27
        }
28
29
        return '';
30
    }
31
32
    public function getSummaryAttribute(): string
33
    {
34
        return "{$this->status_as_emoji}  {$this->type}: {$this->message}";
0 ignored issues
show
Bug introduced by
The property status_as_emoji does not seem to exist. Did you mean status?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Bug introduced by
The property type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property message does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
35
    }
36
37
    public function getLatestRunDiffAttribute(): string
38
    {
39
        if (! $this->checked_at) {
0 ignored issues
show
Bug introduced by
The property checked_at does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
40
            return 'Did not run yet';
41
        }
42
43
        return $this->checked_at->diffForHumans();
44
    }
45
46
    public function getNextRunDiffAttribute(): string
47
    {
48
        if (! $this->next_check_in_minutes) {
0 ignored issues
show
Bug introduced by
The property next_check_in_minutes does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
49
            return 'As soon as possible';
50
        }
51
52
        return Carbon::now()->addMinutes($this->next_check_in_minutes)->diffForHumans();
53
    }
54
}
55