Test Failed
Push — master ( 13dcda...44dfad )
by Antonio Carlos
04:33
created

Horizon   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 36.36%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 4
cts 11
cp 0.3636
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 6 2
A horizonIsRunning() 0 12 3
1
<?php
2
3
namespace PragmaRX\Health\Checkers;
4
5
use Laravel\Horizon\Contracts\MasterSupervisorRepository;
6
7
class Horizon extends Base
8
{
9
    /**
10
     * Check resource.
11
     *
12
     * @return \PragmaRX\Health\Support\Result
13
     */
14 1
    public function check()
15
    {
16 1
        return $this->horizonIsRunning()
17
            ? $this->makeHealthyResult()
18
            : $this->makeResult(false, $this->target->getErrorMessage());
19
    }
20
21
    /**
22
     * Check if Horizon is up.
23
     *
24
     * @return bool
25
     */
26 1
    protected function horizonIsRunning()
27
    {
28 1
        if (!$masters = app(MasterSupervisorRepository::class)->all()) {
29
            return false;
30
        }
31
32
        return collect($masters)->contains(function ($master) {
33
            return $master->status === 'paused';
34
        })
35
            ? false
36
            : true;
37
    }
38
}
39