DeleteIndexHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 2
1
<?php
2
3
namespace GBProd\ElasticaExtraBundle\Handler;
4
5
use GBProd\ElasticaExtraBundle\Exception\IndexNotFoundException;
6
use Elastica\Client;
7
8
/**
9
 * Handler to delete index command
10
 *
11
 * @author gbprod <[email protected]>
12
 */
13
class DeleteIndexHandler
14
{
15
    /**
16
     * Handle index deletion command
17
     *
18
     * @param Client $client
19
     * @param string $index
20
     *
21
     * @throws IndexNotFoundException
22
     */
23 2
    public function handle(Client $client, $index)
24
    {
25 2
        $index = $client->getIndex($index);
26
27 2
        if (!$index->exists()) {
28 1
            throw new IndexNotFoundException($index);
0 ignored issues
show
Documentation introduced by
$index is of type object<Elastica\Index>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29
        }
30
31 1
        $index->delete();
32 1
    }
33
}
34