HealthContributorRegistry::getAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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