Completed
Push — master ( 69fc0f...436aa0 )
by Kirill
05:37
created

ArgumentInvocation::getDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 6
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Reflection\Invocation\Dependent;
11
12
use Railt\Reflection\Contracts\Definition\Behaviour\ProvidesArguments;
13
use Railt\Reflection\Contracts\Definition\TypeDefinition;
14
use Railt\Reflection\Contracts\Invocation\Dependent\ArgumentInvocation as ArgumentInvocationInterface;
15
use Railt\Reflection\Contracts\Invocation\TypeInvocation;
16
use Railt\Reflection\Contracts\Type;
17
use Railt\Reflection\Definition\Dependent\ArgumentDefinition;
18
use Railt\Reflection\Document;
19
20
/**
21
 * Class ArgumentInvocation
22
 */
23
class ArgumentInvocation extends AbstractDependentTypeInvocation implements ArgumentInvocationInterface
24
{
25
    /**
26
     * @var mixed
27
     */
28
    protected $value;
29
30
    /**
31
     * ArgumentInvocation constructor.
32
     * @param TypeInvocation $parent
33
     * @param Document $document
34
     * @param string $name
35
     * @param mixed $value
36
     */
37
    public function __construct(TypeInvocation $parent, Document $document, string $name, $value)
38
    {
39
        $this->value = $value;
40
41
        parent::__construct($parent, $document, $name);
42
    }
43
44
    /**
45
     * @return Type
46
     */
47
    public static function getType(): Type
48
    {
49
        return ArgumentDefinition::getType();
50
    }
51
52
    /**
53
     * @return mixed
54
     */
55
    public function getValue()
56
    {
57
        return $this->value;
58
    }
59
60
    /**
61
     * @return TypeDefinition
62
     */
63
    public function getDefinition(): TypeDefinition
64
    {
65
        /** @var ProvidesArguments $parent */
66
        $parent = $this->getParentInvocation()->getDefinition();
67
68
        \assert($parent instanceof ProvidesArguments);
69
70
        return $parent->getArgument($this->name);
71
    }
72
}
73