Failed Conditions
Pull Request — master (#1)
by GBProd
04:30 queued 01:36
created

ElasticaServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getServices() 0 11 1
1
<?php
2
3
namespace GBProd;
4
5
use Elastica\Client;
6
use Interop\Container\ContainerInterface;
7
use Interop\Container\ServiceProvider;
8
9
/**
10
 * Service provider for Elastica
11
 *
12
 * @author GBProd <[email protected]>
13
 */
14
class ElasticaServiceProvider implements ServiceProvider
15
{
16
    /**
17
     * @var string
18
     */
19
    private $suffix;
20
21
    /**
22
     * @param string $suffix
0 ignored issues
show
Documentation introduced by
Should the type for parameter $suffix not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
23
     */
24 2
    public function __construct($suffix = null)
25
    {
26 2
        $this->suffix = $suffix ? '.'.$suffix : '';
27 2
    }
28
29
    /**
30
     * {inheritdoc}
31
     */
32
    public function getServices()
33
    {
34
        return [
35 2
            Client::class.$this->suffix => function (ContainerInterface $container) {
36 2
                return new Client([
37 2
                    'host' => $container->get(Client::class.$this->suffix.'.host'),
38 2
                    'port' => $container->get(Client::class.$this->suffix.'.port')
39
                ]);
40 2
            }
41
        ];
42
    }
43
}
44