Passed
Push — master ( 0db7f5...3c2912 )
by Ben
74:34 queued 68:06
created

Monitor::check()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 3
nc 3
nop 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Thinktomorrow\Chief\HealthMonitor;
6
7
use Thinktomorrow\Chief\HealthMonitor\Checks\HomepageCheck;
8
use Thinktomorrow\Chief\HealthMonitor\Notifiers\AlertBarNotifier;
9
10
class Monitor
11
{
12
    private static $checks = [
13
        HomepageCheck::class => AlertBarNotifier::class
14
    ];
15
16
    public static function check()
17
    {
18
        foreach(static::$checks as $check => $notifier)
0 ignored issues
show
Bug introduced by
Since $checks is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $checks to at least protected.
Loading history...
19
        {
20
            $checker = (new $check);
21
            $notifier = (new $notifier);
22
            
23
            if(!$checker->check())
24
            {
25
                return $notifier->notify($checker->notify());
26
            }
27
        } 
28
    }
29
}
30