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

AbstractHealthIndicator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 23
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
doHealthCheck() 0 1 ?
A health() 0 11 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
 * @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