| Total Complexity | 5 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 6 | ||
| Bugs | 1 | Features | 3 |
| 1 | <?php |
||
| 7 | class Forwarding |
||
| 8 | { |
||
| 9 | public const CONTAINER_KEY = '_forwarding'; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @var class-string |
||
|
|
|||
| 13 | */ |
||
| 14 | public string $pendingClass; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Initialize the forwarding. |
||
| 18 | */ |
||
| 19 | 21 | public static function enable(): self |
|
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Define the pending class. |
||
| 26 | */ |
||
| 27 | 22 | public function from(string $class): static |
|
| 28 | { |
||
| 29 | 22 | $this->pendingClass = $this->resolve($class); |
|
| 30 | |||
| 31 | 22 | return $this; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Define the forwarding for the pending class set previously. |
||
| 36 | */ |
||
| 37 | 21 | public function to(string $destination): static |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Extract an implementation from the interface if passed. |
||
| 49 | */ |
||
| 50 | 22 | protected function resolve(string $class): string |
|
| 55 |