Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
Definition
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
7 / 7
8
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 getAlias
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getClassString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConstructorArgs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addConstructorArgs
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getMethodCalls
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addMethodCall
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace pvc\container\defs;
6
7use pvc\interfaces\container\DefinitionInterface;
8use pvc\interfaces\container\MethodCallInterface;
9
10class Definition implements DefinitionInterface
11{
12    /**
13     * @var string
14     */
15    protected string $alias;
16
17    /**
18     * @var string
19     */
20    protected string $classString;
21
22    /**
23     * @var array<mixed>
24     */
25    protected array $constructorArgs = [];
26
27    /**
28     * @var array<MethodCallInterface>
29     */
30    protected array $methodCalls = [];
31
32    /**
33     * @param  string  $aliasOrClassString
34     * @param  ?string  $classString
35     */
36    public function __construct(string $aliasOrClassString, ?string $classString = null)
37    {
38        if (null !== $classString) {
39               $this->alias = $aliasOrClassString;
40               $this->classString = $classString;
41        } else {
42                $this->alias = $aliasOrClassString;
43                $this->classString = $aliasOrClassString;
44        }
45    }
46
47    public function getAlias(): string
48    {
49        return $this->alias;
50    }
51
52    public function getClassString(): string
53    {
54        return $this->classString;
55    }
56
57    /**
58     * getConstructorArgs
59     * @return array<mixed>
60     */
61    public function getConstructorArgs(): array
62    {
63        return $this->constructorArgs;
64    }
65
66    /**
67     * addConstructorArgs
68     * @param  mixed  $args
69     *
70     * @return DefinitionInterface
71     */
72    public function addConstructorArgs(... $args): DefinitionInterface
73    {
74        $this->constructorArgs = array_merge($this->constructorArgs, $args);
75        return $this;
76    }
77
78    /**
79     * getMethodCalls
80     * @return array<MethodCallInterface>
81     */
82    public function getMethodCalls(): array
83    {
84        return $this->methodCalls;
85    }
86
87    /**
88     * addMethodCall
89     * @param  string  $methodName
90     * @param mixed|null $args
91     *
92     * @return DefinitionInterface
93     */
94    public function addMethodCall(string $methodName, ... $args): DefinitionInterface
95    {
96        $this->methodCalls[] = new MethodCall($methodName, ... $args);
97        return $this;
98    }
99}