| Conditions | 3 |
| Paths | 1 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | 307 | public function __construct( |
|
| 19 | callable $callable, |
||
| 20 | public readonly bool $singleton = false, |
||
| 21 | ) { |
||
| 22 | 307 | $this->factory = $callable(...); |
|
| 23 | 307 | $this->parametersCount = (new \ReflectionFunction($this->factory))->getNumberOfParameters(); |
|
| 24 | /** @psalm-suppress TypeDoesNotContainType */ |
||
| 25 | 307 | $this->definition = match (true) { |
|
| 26 | 307 | \is_string($callable) => $callable, |
|
| 27 | 307 | \is_array($callable) => \sprintf( |
|
| 28 | 307 | '%s::%s()', |
|
| 29 | 307 | \is_object($callable[0]) ? $callable[0]::class : $callable[0], |
|
| 30 | 307 | $callable[1], |
|
| 31 | 307 | ), |
|
| 32 | 307 | \is_object($callable) && $callable::class !== \Closure::class => 'object ' . $callable::class, |
|
| 33 | 307 | default => null, |
|
| 34 | 307 | }; |
|
| 52 |