| Total Complexity | 4 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | final class ExtensibleService implements DefinitionInterface |
||
| 22 | { |
||
| 23 | private DefinitionInterface $definition; |
||
| 24 | private array $extensions = []; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param DefinitionInterface $definition Definition to allow registering extensions for. |
||
| 28 | */ |
||
| 29 | public function __construct(DefinitionInterface $definition) |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Add an extension. |
||
| 36 | * |
||
| 37 | * An extension is a callable that returns a modified service object: |
||
| 38 | * |
||
| 39 | * ```php |
||
| 40 | * static function (ContainerInterface $container, $service) { |
||
| 41 | * return $service->withAnotherOption(42); |
||
| 42 | * } |
||
| 43 | * ``` |
||
| 44 | * |
||
| 45 | * @param callable $closure An extension to register. |
||
| 46 | */ |
||
| 47 | public function addExtension(callable $closure): void |
||
| 48 | { |
||
| 49 | $this->extensions[] = $closure; |
||
| 50 | } |
||
| 51 | |||
| 52 | public function resolve(DependencyResolverInterface $container) |
||
| 61 | } |
||
| 62 | } |
||
| 63 |