AbstractHealthIndicator::doHealthCheck()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 1
ccs 0
cts 0
cp 0
nc 1
1
<?php
2
3
namespace Actuator\Health\Indicator;
4
5
use Actuator\Health\HealthBuilder;
6
7
/**
8
 * Base HealthIndicator implementations that encapsulates creation of
9
 * Health instance and error handling.
10
 */
11
abstract class AbstractHealthIndicator implements HealthIndicatorInterface
12
{
13
    public function health()
14
    {
15 36
        $builder = new HealthBuilder();
16
        try {
17 36
            $this->doHealthCheck($builder);
18
        } catch (\Exception $e) {
19 36
            $builder->down($e);
20 36
        }
21 3
22
        return $builder->build();
23
    }
24 36
25 3
    /**
26
     * Actual health check logic.
27
     *
28
     * @param HealthBuilder $builder
29
     *
30
     * @throws \Exception any Exception that should create a Status::DOWN
31
     *                    system status.
32
     */
33
    abstract protected function doHealthCheck(HealthBuilder $builder);
34
}
35