StorageMetadataFactory::handleLoad()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace As3\Modlr\Search\Elastic;
4
5
use As3\Modlr\Exception\MetadataException;
6
use As3\Modlr\Metadata\EntityMetadata;
7
use As3\Modlr\Metadata\Interfaces\StorageLayerInterface;
8
use As3\Modlr\Metadata\Interfaces\StorageMetadataFactoryInterface;
9
use As3\Modlr\Util\EntityUtility;
10
11
/**
12
 * Creates Elastic search storage Metadata instances for use with metadata drivers.
13
 * Is also responsible for validating storage objects.
14
 *
15
 * @author Jacob Bare <[email protected]>
16
 */
17
final class StorageMetadataFactory implements StorageMetadataFactoryInterface
18
{
19
    /**
20
     * {@inheritDoc}
21
     */
22
    public function createInstance(array $mapping)
23
    {
24
        $search = new StorageMetadata();
25
        if (isset($mapping['index'])) {
26
            $search->index = $mapping['index'];
27
        }
28
29
        if (isset($mapping['type'])) {
30
            $search->type = $mapping['type'];
31
        }
32
        return $search;
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    public function handleLoad(EntityMetadata $metadata)
39
    {
40
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45
    public function handleValidate(EntityMetadata $metadata)
46
    {
47
        $search = $metadata->search;
0 ignored issues
show
Unused Code introduced by
$search is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
48
    }
49
50
51
}
52