Redis::call()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 14
rs 10
cc 2
nc 3
nop 0
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