Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| CallableResolver | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| resolve | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| creator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Wire; |
| 6 | |
| 7 | use Closure; |
| 8 | use Override; |
| 9 | use ReflectionFunction; |
| 10 | |
| 11 | /** @psalm-api */ |
| 12 | class CallableResolver |
| 13 | { |
| 14 | use ResolvesAbstractFunctions; |
| 15 | |
| 16 | public function __construct( |
| 17 | protected readonly CreatorInterface $creator, |
| 18 | ) {} |
| 19 | |
| 20 | /** @param callable $callable */ |
| 21 | public function resolve( |
| 22 | array|callable $callable, |
| 23 | array $predefinedArgs = [], |
| 24 | array $predefinedTypes = [], |
| 25 | ?callable $injectCallback = null, |
| 26 | ): array { |
| 27 | $callable = Closure::fromCallable($callable); |
| 28 | $rfn = new ReflectionFunction($callable); |
| 29 | |
| 30 | return $this->resolveArgs($rfn, $predefinedArgs, $predefinedTypes, $injectCallback); |
| 31 | } |
| 32 | |
| 33 | #[Override] |
| 34 | public function creator(): CreatorInterface |
| 35 | { |
| 36 | return $this->creator; |
| 37 | } |
| 38 | } |