Client   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 35
ccs 0
cts 15
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getInstance() 0 14 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...
Coding Style introduced by
The property $ELASTICSEARCH_DEFAULT_HOST is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
11
{
12
    private static $ELASTICSEARCH_DEFAULT_HOST = 'elasticsearch:9200';
0 ignored issues
show
Coding Style introduced by
$ELASTICSEARCH_DEFAULT_HOST does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
13
14
    /**
15
     * @var \Elasticsearch\Client
16
     */
17
    private static $instance;
18
19
    /**
20
     * To avoid the direct construction
21
     */
22
    private function __construct()
23
    {
24
    }
25
26
    /**
27
     * Returns ElasticSearch client object
28
     * @return \Elasticsearch\Client
29
     */
30
    public static function getInstance()
31
    {
32
        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...
33
            $logger = ClientBuilder::defaultLogger('flightspy_elasticsearch.log');
34
35
            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...
36
                ->setHosts([static::$ELASTICSEARCH_DEFAULT_HOST])
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...
37
                ->setRetries(2)
38
                ->setLogger($logger)
39
                ->build();
40
        }
41
42
        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...
43
    }
44
}
45