Completed
Push — master ( 46aa7e...25bb06 )
by Freek
01:56
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\Helpers\Emoji;
6
use Spatie\ServerMonitor\Models\Enums\CheckStatus;
7
8
trait CheckPresenter
9
{
10
    public function getStatusAsEmojiAttribute(): 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
    public function getSummaryAttribute(): string
32
    {
33
        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...
34
    }
35
}
36