Completed
Push — master ( 464304...ae781e )
by Jean
05:57
created

Client::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * @author Jean Silva <[email protected]>
4
 * @license MIT
5
 */
6
namespace Jeancsil\FlightSpy\Service\ElasticSearch;
7
8
use Elasticsearch\ClientBuilder;
9
10
final class Client
0 ignored issues
show
Coding Style introduced by
Client does not seem to conform to the naming convention (Utils?$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
11
{
12
    /**
13
     * @var \Elasticsearch\Client
14
     */
15
    private static $instance;
16
17
    /**
18
     * To avoid the direct construction
19
     */
20
    private function __construct()
21
    {
22
    }
23
24
    /**
25
     * Returns ElasticSearch client object
26
     * @return \Elasticsearch\Client
27
     */
28
    public static function getInstance() {
29
        if (is_null(static::$instance)) {
0 ignored issues
show
Comprehensibility introduced by
Since Jeancsil\FlightSpy\Service\ElasticSearch\Client is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
30
            $logger = ClientBuilder::defaultLogger('flightspy_elasticsearch.log');
31
32
            static::$instance = ClientBuilder::create()
0 ignored issues
show
Comprehensibility introduced by
Since Jeancsil\FlightSpy\Service\ElasticSearch\Client is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
33
                ->setRetries(2)
34
                ->setLogger($logger)
35
                ->build();
36
        }
37
38
        return static::$instance;
0 ignored issues
show
Comprehensibility introduced by
Since Jeancsil\FlightSpy\Service\ElasticSearch\Client is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
39
    }
40
}
41