Completed
Push — master ( 1d6659...7b4605 )
by Bret R.
05:07
created

ElasticsearchCheck::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace BretRZaun\StatusPage\Check;
3
4
use BretRZaun\StatusPage\Result;
5
use Elasticsearch\Client;
6
7
class ElasticsearchCheck extends AbstractCheck
8
{
9
10
    /**
11
     * @var Client
12
     */
13
    protected $client;
14
15
    /**
16
     * Constructor
17
     *
18
     * @param $label
19
     * @param Client $client
20
     */
21
    public function __construct($label, Client $client)
22
    {
23
        parent::__construct($label);
24
        $this->client = $client;
25
    }
26
27
    /**
28
     * Check callback
29
     *
30
     * @return Result
31
     */
32
    public function check()
33
    {
34
        $result = new Result($this->label);
35
        if ($this->client->ping() !== true) {
36
            $result->setSuccess(false);
37
        }
38
        return $result;
39
    }
40
}
41