Completed
Push — master ( 3b79f3...426227 )
by Kirill
03:11
created

ArgumentBuilder::buildArguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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\Adapters\Webonyx\Builders;
11
12
use Railt\Adapters\Webonyx\Registry;
13
use Railt\Reflection\Contracts\Dependent\Argument\HasArguments;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Contrac...t\Argument\HasArguments was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Railt\Reflection\Contracts\Dependent\ArgumentDefinition as ReflectionArgument;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Contrac...dent\ArgumentDefinition was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * @property ReflectionArgument $reflection
18
 */
19
class ArgumentBuilder extends DependentDefinitionBuilder
20
{
21
    /**
22
     * @param HasArguments $type
23
     * @param Registry $registry
24
     * @return array
25
     * @throws \InvalidArgumentException
26
     */
27
    public static function buildArguments(HasArguments $type, Registry $registry): array
28
    {
29
        $result = [];
30
31
        foreach ($type->getArguments() as $argument) {
32
            $result[$argument->getName()] = (new static($argument, $registry))->build();
33
        }
34
35
        return $result;
36
    }
37
38
    /**
39
     * @return array
40
     * @throws \InvalidArgumentException
41
     */
42
    public function build(): array
43
    {
44
        $config = [
45
            'name'        => $this->reflection->getName(),
46
            'description' => $this->reflection->getDescription(),
47
            'type'        => $this->buildType(),
48
        ];
49
50
        if ($this->reflection->isDeprecated()) {
51
            $config['deprecationReason'] = $this->reflection->getDeprecationReason();
52
        }
53
54
        if ($this->reflection->hasDefaultValue()) {
55
            $config['defaultValue'] = $this->reflection->getDefaultValue();
56
        }
57
58
        return $config;
59
    }
60
}
61