HealthContributorRegistry   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A getAll() 0 4 1
A findByName() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nwidart\Actuator\Health;
6
7
use Illuminate\Support\Collection;
8
9
class HealthContributorRegistry
10
{
11
    private $contributors = [];
12
13 8
    public function register(string $name, HealthContributor $class): void
14
    {
15 8
        $this->contributors[$name] = $class;
16 8
    }
17
18
    /**
19
     * @return Collection
20
     */
21 8
    public function getAll(): Collection
22
    {
23 8
        return collect($this->contributors);
24
    }
25
26 2
    public function findByName(string $name): ?HealthContributor
27
    {
28 2
        if (! array_key_exists($name, $this->contributors)) {
29 1
            return null;
30
        }
31
32 1
        return $this->contributors[$name];
33
    }
34
}
35