Completed
Push — master ( fe009d...c8291b )
by Avtandil
02:46
created

HorizonIsRunning::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Longman\LaravelLodash\SelfDiagnosis\Checks;
6
7
use BeyondCode\SelfDiagnosis\Checks\Check;
8
use Laravel\Horizon\Contracts\MasterSupervisorRepository;
9
10
use function collect;
11
use function trans;
12
13
class HorizonIsRunning implements Check
14
{
15
    /**
16
     * @var \Laravel\Horizon\Contracts\MasterSupervisorRepository
17
     */
18
    private $supervisorRepository;
19
20
    public function __construct(MasterSupervisorRepository $supervisorRepository)
21
    {
22
        $this->supervisorRepository = $supervisorRepository;
23
    }
24
25
    public function name(array $config): string
26
    {
27
        return trans('lodash::checks.horizon_is_running.name');
28
    }
29
30
    public function check(array $config): bool
31
    {
32
        if (! $masters = $this->supervisorRepository->all()) {
33
            return false;
34
        }
35
36
        return ! collect($masters)->contains(static function ($master) {
37
            return $master->status === 'paused';
38
        });
39
    }
40
41
    public function message(array $config): string
42
    {
43
        return trans('lodash::checks.horizon_is_running.message');
44
    }
45
}
46