Test Failed
Push — master ( da2c9c...d0cc4d )
by Kirill
02:03
created

HasArguments::getArgumentDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
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\Definition\Behaviour;
11
12
use Railt\Reflection\Contracts\Definition\Behaviour\ProvidesArguments;
13
use Railt\Reflection\Definition\Dependent\ArgumentDefinition;
14
use Railt\Reflection\Contracts\Definition\Dependent\ArgumentDefinition as ArgumentDefinitionInterface;
15
16
/**
17
 * Trait HasArguments
18
 * @mixin ProvidesArguments
19
 */
20
trait HasArguments
21
{
22
    /**
23
     * @var array|ArgumentDefinition[]
24
     */
25
    protected $arguments = [];
26
27
    /**
28
     * @return iterable|ArgumentDefinition[]
29
     */
30
    public function getArgumentDefinitions(): iterable
31
    {
32
        return \array_values($this->arguments);
33
    }
34
35
    /**
36
     * @param string $name
37
     * @return bool
38
     */
39
    public function hasArgumentDefinition(string $name): bool
40
    {
41
        return isset($this->arguments[$name]);
42
    }
43
44
    /**
45
     * @param string $name
46
     * @return null|ArgumentDefinitionInterface
47
     */
48
    public function getArgumentDefinition(string $name): ?ArgumentDefinitionInterface
49
    {
50
        return $this->arguments[$name] ?? null;
51
    }
52
53
    /**
54
     * @param ArgumentDefinitionInterface $argument
55
     */
56
    public function addArgument(ArgumentDefinitionInterface $argument): void
57
    {
58
        $this->arguments[$argument->getName()] = $argument;
59
    }
60
}
61