Completed
Push — master ( d72a06...ba0ad0 )
by GBProd
04:38
created

DeleteIndexHandler::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 15
loc 15
ccs 7
cts 8
cp 0.875
rs 9.4285
cc 2
eloc 8
nc 2
nop 2
crap 2.0078
1
<?php
2
3
namespace GBProd\ElasticsearchExtraBundle\Handler;
4
5
use Elasticsearch\Client;
6
use GBProd\ElasticsearchExtraBundle\Repository\IndexConfigurationRepository;
7
8
/**
9
 * Handler to delete index command
10
 *
11
 * @author gbprod <[email protected]>
12
 */
13 View Code Duplication
class DeleteIndexHandler
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...
14
{
15
    /**
16
     * @var IndexConfigurationRepository
17
     */
18
    private $configurationRepository;
19
20
    /**
21
     * @param IndexConfigurationRepository $configurationRepository
22
     */
23
    public function __construct(IndexConfigurationRepository $configurationRepository)
24
    {
25 1
        $this->configurationRepository = $configurationRepository;
26 1
    }
27
28
    /**
29
     * Handle index deletion command
30
     *
31
     * @param Client $client
32
     * @param string $index
33
     */
34
    public function handle(Client $client, $index)
35
    {
36 1
        $config = $this->configurationRepository->get($index);
37
38 1
        if (null === $config) {
39
            throw new \InvalidArgumentException();
40
        }
41
42
        $client
43 1
            ->indices()
44 1
            ->delete([
45 1
                'index' => $index,
46 1
            ])
47
        ;
48 1
    }
49
}
50