Completed
Push — master ( 103460...224772 )
by GBProd
02:10
created

PutIndexSettingsHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A handle() 16 16 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 $configurationRepository;
20
21
    /**
22
     * @param IndexConfigurationRepository $configurationRepository
23
     */
24 3
    public function __construct(IndexConfigurationRepository $configurationRepository)
25
    {
26 3
        $this->configurationRepository = $configurationRepository;
27 3
    }
28
29
    /**
30
     * Handle index creation command
31
     *
32
     * @param Client $client
33
     * @param string $index
34
     */
35 2
    public function handle(Client $client, $index)
36
    {
37 2
        $settings = $this
38
            ->configurationRepository
39 2
            ->getSettings($index)
40 2
        ;
41
42 2
        if (null === $settings) {
43 1
            throw new \InvalidArgumentException();
44
        }
45
46
        $client
47 1
            ->getIndex($index)
48 1
            ->setSettings($settings)
49
        ;
50 1
    }
51
52
}
53