Completed
Pull Request — master (#6)
by
unknown
02:20
created

CheckPresenter::getCheckStatusAsEmojiAttribute()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 10
nc 5
nop 0
1
<?php
2
3
namespace Spatie\ServerMonitor\Models\Presenters;
4
5
use Spatie\ServerMonitor\Models\Enums\CheckStatus;
6
use Spatie\ServerMonitor\Helpers\Emoji;
7
8
trait CheckPresenter
9
{
10
    public function getCheckStatusAsEmojiAttribute(): string
11
    {
12
        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...
13
            return Emoji::ok();
14
        }
15
16
        if ($this->status === CheckStatus::FAILED) {
17
            return Emoji::notOk();
18
        }
19
20
        if ($this->status === CheckStatus::WARNING) {
21
            return Emoji::warning();
22
        }
23
24
        if ($this->status === CheckStatus::NOT_YET_CHECKED) {
25
            return Emoji::unknown();
26
        }
27
28
        return '';
29
    }
30
}
31