HorizonIsRunning   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A name() 0 4 1
A message() 0 4 1
A check() 0 11 2
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
        $masters = $this->supervisorRepository->all();
33
        if (! $masters) {
34
            return false;
35
        }
36
37
        return ! collect($masters)->contains(static function ($master) {
38
            return $master->status === 'paused';
39
        });
40
    }
41
42
    public function message(array $config): string
43
    {
44
        return trans('lodash::checks.horizon_is_running.message');
45
    }
46
}
47