Completed
Push — master ( 9ef8fc...cc978d )
by John
14:22
created

BaseMemcacheHealthIndicator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 33
rs 10

1 Method

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