class Conditional implements ExtenderInterface
The Conditional extender allows developers to conditionally apply other extenders based on either boolean values or results from callable functions.
This is useful for applying extenders only if certain conditions are met, such as the presence of an enabled extension or a specific configuration setting.
Properties
| protected array | $conditions | An array of conditions and their associated extenders. |
|
Methods
Apply extenders only if a specific extension is enabled.
Apply extenders only if a specific extension is disabled.
Apply extenders only if a setting matches an expected value.
Apply extenders based on a condition.
Iterates over the conditions and applies the associated extenders if the conditions are met.
Details
at
line 43
Conditional
whenExtensionEnabled(string $extensionId, callable|string $extenders)
Apply extenders only if a specific extension is enabled.
at
line 56
Conditional
whenExtensionDisabled(string $extensionId, callable|string $extenders)
Apply extenders only if a specific extension is disabled.
at
line 71
Conditional
whenSetting(string $key, mixed $expected, callable|string $extenders, bool $strict = false)
Apply extenders only if a setting matches an expected value.
at
line 87
Conditional
when(callable|bool $condition, callable|string $extenders)
Apply extenders based on a condition.
at
line 100
void
extend(Container $container, Extension|null $extension = null)
Iterates over the conditions and applies the associated extenders if the conditions are met.