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

Horizon::horizonIsRunning()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 6.28

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 12
ccs 2
cts 7
cp 0.2857
crap 6.28
rs 9.8666
c 0
b 0
f 0
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