AbstractHealthIndicator::health()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
crap 2
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