Passed
Push — fix/radiobuttonstyling ( e57dd3...53f350 )
by Ben
15:46 queued 08:51
created

Monitor   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 7
eloc 15
c 3
b 1
f 0
dl 0
loc 29
ccs 7
cts 8
cp 0.875
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A check() 0 19 6
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Thinktomorrow\Chief\HealthMonitor;
6
7
use Thinktomorrow\Chief\HealthMonitor\Checks\HealthCheck;
8
use Thinktomorrow\Chief\HealthMonitor\Exceptions\InvalidClassException;
9
10
class Monitor
11
{
12
    private $checks = [
13
    ];
14
15
    public function __construct()
16
    {
17
        $this->checks = config('thinktomorrow.chief.healthMonitor', []);
18 32
    }
19
20 32
    public function check()
21 32
    {
22
        foreach ($this->checks as $check) {
23 32
            $checkInstance = app($check);
24 32
            
25 32
            if (! $checkInstance instanceof HealthCheck) {
26
                throw new InvalidClassException('Checks must implement Healthcheck interface.');
27 1
            }
28
29
            $notifiers = $checkInstance->notifiers();
30
31
            if (!$checkInstance->check()) {
32
                foreach ($notifiers as $notifier) {
33
                    app($notifier)->onFailure($checkInstance);
0 ignored issues
show
Bug introduced by
The method onFailure() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
                    app($notifier)->/** @scrutinizer ignore-call */ onFailure($checkInstance);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
                }
35
                return;
36
            } else {
37
                foreach ($notifiers as $notifier) {
38
                    app($notifier)->onSuccess($checkInstance);
0 ignored issues
show
Bug introduced by
The method onSuccess() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
                    app($notifier)->/** @scrutinizer ignore-call */ onSuccess($checkInstance);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
                }
40
            }
41
        }
42
    }
43
}
44