Completed
Push — master ( 611e0d...3b7232 )
by Kirill
02:21
created

HasPassedArguments   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 44
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getArguments() 0 4 1
A hasArgument() 0 4 1
A getArgument() 0 4 1
A withArgument() 0 6 1
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\Behaviour;
11
12
use Railt\Reflection\Contracts\Invocation\Behaviour\ProvidesPassedArguments;
13
use Railt\Reflection\Contracts\Invocation\Dependent\ArgumentInvocation;
14
15
/**
16
 * Trait HasPassedArguments
17
 * @mixin ProvidesPassedArguments
18
 */
19
trait HasPassedArguments
20
{
21
    /**
22
     * @var array|ArgumentInvocation[]
23
     */
24
    protected $arguments = [];
25
26
    /**
27
     * @return iterable|ArgumentInvocation[]
28
     */
29
    public function getArguments(): iterable
30
    {
31
        return \array_values($this->arguments);
32
    }
33
34
    /**
35
     * @param string $name
36
     * @return bool
37
     */
38
    public function hasArgument(string $name): bool
39
    {
40
        return isset($this->arguments[$name]);
41
    }
42
43
    /**
44
     * @param string $name
45
     * @return null|ArgumentInvocation
46
     */
47
    public function getArgument(string $name): ?ArgumentInvocation
48
    {
49
        return $this->arguments[$name] ?? null;
50
    }
51
52
    /**
53
     * @param ArgumentInvocation $argument
54
     * @return ProvidesPassedArguments
55
     */
56
    public function withArgument(ArgumentInvocation $argument): ProvidesPassedArguments
57
    {
58
        $this->arguments[$argument->getName()] = $argument;
59
60
        return $this;
61
    }
62
}
63