Passed
Push — master ( 80b49c...d38ed3 )
by Filipe
02:26 queued 14s
created

ConstructorArgumentInspector::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 1
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