SimpleStatus::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus;
6
7
use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus;
8
9
final class SimpleStatus implements DependencyStatus
10
{
11
    public const KEY_INFO = 'info';
12
13
    private string $name;
14
15
    private bool $healthy;
16
17
    private mixed $info;
18
19
    /**
20
     * @param string $name
21
     * @param bool $healthy
22
     * @param mixed|null $info
23
     */
24
    public function __construct(string $name, bool $healthy, mixed $info = null)
25
    {
26
        $this->name = $name;
27
        $this->healthy = $healthy;
28
        $this->info = $info;
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function getName(): string
35
    {
36
        return $this->name;
37
    }
38
39
    /**
40
     * @return bool
41
     */
42
    public function isHealthy(): bool
43
    {
44
        return $this->healthy;
45
    }
46
47
    /**
48
     * @return mixed
49
     */
50
    public function getInfo(): mixed
51
    {
52
        return $this->info;
53
    }
54
55
    /**
56
     * @return array{'name':string,'healthy': bool, 'info': mixed}
57
     */
58
    public function jsonSerialize(): array
59
    {
60
        return [
61
            self::KEY_NAME => $this->getName(),
62
            self::KEY_HEALTHY => $this->isHealthy(),
63
            self::KEY_INFO => $this->getInfo(),
64
        ];
65
    }
66
}
67