PutIndexSettingsHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A handle() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace GBProd\ElasticaExtraBundle\Handler;
4
5
use Elastica\Client;
6
use GBProd\ElasticaExtraBundle\Repository\ClientRepository;
7
use GBProd\ElasticaExtraBundle\Repository\IndexConfigurationRepository;
8
9
/**
10
 * Handler to put index settings command
11
 *
12
 * @author gbprod <[email protected]>
13
 */
14 View Code Duplication
class PutIndexSettingsHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * @var IndexConfigurationRepository
18
     */
19
    private $configurations;
20
21
    /**
22
     * @param IndexConfigurationRepository $configurations
23
     */
24 3
    public function __construct(IndexConfigurationRepository $configurations)
25
    {
26 3
        $this->configurations = $configurations;
27 3
    }
28
29
    /**
30
     * Handle index creation command
31
     *
32
     * @param Client $client
33
     * @param string $index
34
     * @param string $alias
35
     */
36 2
    public function handle(Client $client, $index, $alias)
37
    {
38 2
        $settings = $this->configurations->getSettings($alias);
39
40 2
        if (null === $settings) {
41 1
            throw new \InvalidArgumentException();
42
        }
43
44 1
        $client->getIndex($index)->setSettings($settings);
45 1
    }
46
47
}
48