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

HasArguments   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
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 41
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getArgumentDefinitions() 0 4 1
A hasArgumentDefinition() 0 4 1
A getArgumentDefinition() 0 4 1
A addArgument() 0 4 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\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