PutIndexSettingsHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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