Completed
Branch master (f2efac)
by John
02:31
created

AbstractHealthIndicator::doHealthCheck()

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
 * @package Actuator\Health\Indicator
12
 */
13
abstract class AbstractHealthIndicator implements HealthIndicatorInterface
14
{
15 36
    public function health()
16
    {
17 36
        $builder = new HealthBuilder();
18
        try {
19 36
            $this->doHealthCheck($builder);
20 36
        } catch (\Exception $e) {
21 3
            $builder->down($e);
22
        }
23
24 36
        return $builder->build();
25 3
    }
26
27
    /**
28
     * Actual health check logic.
29
     *
30
     * @param HealthBuilder $builder
31
     * @throws \Exception any Exception that should create a Status::DOWN
32
     * system status.
33
     */
34
    abstract protected function doHealthCheck(HealthBuilder $builder);
35
}
36