Completed
Push — master ( ebe931...c89697 )
by GBProd
02:12
created

RegistryEntry   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getProvider() 0 4 1
A getIndex() 0 4 1
A getType() 0 4 1
B match() 0 7 6
1
<?php
2
3
namespace GBProd\ElasticsearchDataProviderBundle\DataProvider;
4
5
/**
6
 * Entry for dataprovider registry
7
 *
8
 * @author gbprod <[email protected]>
9
 */
10
class RegistryEntry
11
{
12
    /**
13
     * @var DataProviderInterface
14
     */
15
    private $provider;
16
17
    /**
18
     * @var string
19
     */
20
    private $index;
21
22
    /**
23
     * @var string
24
     */
25
    private $type;
26
27
    /**
28
     * @param DataProvider $provider
0 ignored issues
show
Documentation introduced by
Should the type for parameter $provider not be DataProviderInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
29
     * @param string       $index
30
     * @param string       $type
31
     */
32 3
    public function __construct(DataProviderInterface $provider, $index, $type)
33
    {
34 3
        $this->provider = $provider;
35 3
        $this->index    = $index;
36 3
        $this->type     = $type;
37 3
    }
38
39
    /**
40
     * Get provider
41
     *
42
     * @return DataProviderInterface
43
     */
44 2
    public function getProvider()
45
    {
46 2
        return $this->provider;
47
    }
48
49
    /**
50
     * Get index
51
     *
52
     * @return string
53
     */
54 3
    public function getIndex()
55
    {
56 3
        return $this->index;
57
    }
58
    /**
59
     * Get type
60
     *
61
     * @return string
62
     */
63 3
    public function getType()
64
    {
65 3
        return $this->type;
66
    }
67
    
68 2
    public function match($index, $type)
69
    {
70 2
        return ($this->getIndex() == $index && $this->getType() == $type)
71 2
            || ($this->getIndex() == $index && $type === null)
72 2
            || (null === $index && $type === null)
73 2
        ;
74
    }
75
}