BaseMemcacheHealthIndicator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B doHealthCheck() 0 20 6
1
<?php
2
3
namespace Actuator\Health\Indicator;
4
5
use Actuator\Health\HealthBuilder;
6
7
/**
8
 * Base class for memcache HealthIndicator.
9
 */
10
class BaseMemcacheHealthIndicator extends AbstractHealthIndicator
11
{
12
    /**
13
     * @var \Memcached|\Memcache
14
     */
15
    protected $memcacheInstance;
16
17
    /**
18
     * Actual health check logic.
19
     *
20
     * @param HealthBuilder $builder
21
     *
22
     * @throws \Exception any Exception that should create a Status::DOWN
23
     *                    system status.
24
     */
25
    protected function doHealthCheck(HealthBuilder $builder)
26 18
    {
27
        try {
28
            $version = $this->memcacheInstance->getversion();
29 18
        } catch (\Exception $e) {
30 18
            $builder->down($e);
31 6
32 6
            return;
33
        }
34
35 12
        if ((is_bool($version) && $version === false) ||
36 9
            ((is_array($version) && count($version) === 0))
37 12
        ) {
38 6
            $builder->down();
39 6
40
            return;
41
        }
42 6
43 6
        $builder->up()->withDetail('version', $version);
44
    }
45
}
46