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

Client   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 31
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getInstance() 0 12 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