Failed Conditions
Push — mixed-collections ( 23b545 )
by Michael
03:24
created

Entry::dispatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Parser\Ast\Collection;
6
7
use Doctrine\Annotations\Parser\Ast\ClassConstantFetch;
8
use Doctrine\Annotations\Parser\Ast\ConstantFetch;
9
use Doctrine\Annotations\Parser\Ast\Scalar\IntegerScalar;
10
use Doctrine\Annotations\Parser\Ast\Scalar\StringScalar;
11
use Doctrine\Annotations\Parser\Ast\ValuableNode;
12
use Doctrine\Annotations\Parser\Ast\Value;
13
use Doctrine\Annotations\Parser\Visitor\Visitor;
14
15
final class Entry implements Value
16
{
17
    /** @var StringScalar|IntegerScalar|ConstantFetch|ClassConstantFetch|null */
18
    private $key;
19
20
    /** @var ValuableNode */
21
    private $value;
22
23
    public function __construct(?Value $key, ValuableNode $value)
24
    {
25
        assert(
26
            $key === null
27
            || $key instanceof StringScalar
28
            || $key instanceof IntegerScalar
29
            || $key instanceof ConstantFetch
30
            || $key instanceof ClassConstantFetch
31
        );
32
33
        $this->key   = $key;
34
        $this->value = $value;
35
    }
36
37
    /**
38
     * @return ClassConstantFetch|ConstantFetch|IntegerScalar|StringScalar|null
39
     */
40
    public function getKey() : ?Value
41
    {
42
        return $this->key;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->key could return the type Doctrine\Annotations\Par...arser\Ast\ConstantFetch which is incompatible with the type-hinted return Doctrine\Annotations\Parser\Ast\Value|null. Consider adding an additional type-check to rule them out.
Loading history...
43
    }
44
45
    /**
46
     * @return ValuableNode
47
     */
48
    public function getValue() : ValuableNode
49
    {
50
        return $this->value;
51
    }
52
53
    public function dispatch(Visitor $visitor) : void
54
    {
55
        $visitor->visitCollectionEntry($this);
56
    }
57
}
58