Passed
Push — develop ( 091796...6c7d9d )
by Filipe
13:16 queued 14s
created

ConstructorArgumentInspector::definedArguments()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
nc 4
nop 0
dl 0
loc 20
rs 9.9
c 3
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of slick/di package
5
 *
6
 * For the full copyright and license information, please view the LICENSE.md
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Di\Inspector;
11
12
use ReflectionClass;
13
use ReflectionMethod;
14
use Slick\Di\ContainerInterface;
15
16
/**
17
 * ConstructorArgumentInspector
18
 *
19
 * @package Slick\Di\Inspector
20
 * @author  Filipe Silva <[email protected]>
21
*/
22
final readonly class ConstructorArgumentInspector
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 22 at column 6
Loading history...
23
{
24
    /**
25
     * Creates a ConstructorArgumentInspector
26
     *
27
     * @param ReflectionClass $reflectionClass
28
     * @param ContainerInterface $container
29
     * @param array<string|int, mixed> $override
30
     */
31
    public function __construct(
32
        private ReflectionClass $reflectionClass,
33
        private ContainerInterface $container,
34
        private array $override = []
35
    ) {
36
    }
37
38
    /**
39
     * Returns the list of alias to used as arguments on object definition
40
     *
41
     * @return array
42
     */
43
    public function arguments(): array
44
    {
45
        $method = $this->reflectionClass->getConstructor();
46
        if (!$method instanceof ReflectionMethod) {
47
            return [];
48
        }
49
50
        return (new MethodArgumentInspector(
51
            $method,
52
            $this->container,
53
            $this->override
54
        ))->arguments();
55
    }
56
}
57