Redis   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 2
b 0
f 0
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A call() 0 14 2
1
<?php
2
namespace Health\Checks\Servers;
3
4
use Health\Checks\BaseCheck;
5
use Health\Checks\HealthCheckInterface;
6
use Illuminate\Support\Facades\Redis as RedisFacade;
7
8
class Redis extends BaseCheck implements HealthCheckInterface
9
{
10
11
    /**
12
     *
13
     * {@inheritdoc}
14
     * @see \Health\Checks\HealthCheckInterface::call()
15
     */
16
    public function call()
17
    {
18
        $builder = $this->getBuilder();
19
20
        $name = $this->getParam('name', null);
21
22
        try {
23
            RedisFacade::connection($name);
24
            RedisFacade::ping();
25
        } catch (\Exception $e) {
26
            $builder->down()->withData("error", "Could not open connection to server - " . $e->getMessage());
27
        }
28
29
        return $builder->build();
30
    }
31
}
32