conditional
conditional copied to clipboard
PHP if-else re-imagined
Suggestions: ```php //Switch Condition::switch($value) ->default(new DefaultStrategy) ->case(1, new StrategyA) ->case(2, new StrategyB) ; // Higher Order Proxy to Fluent Str Condition::when($value) ->endsWith('City')->replaceLast(' City', '')->title() ->contains('New York')->uppercase() ->empty(new RandomCity) ; //Delegate...
Instead of: ```php $action = fn() => $action; ``` Use: ```php $action = static fn() => $action; ``` > Does it even have any difference?
Handle case: ```php $result2 = Conditional::if(1 === 'Invocable') ->then(2) ->value(); // No value here or it returns null? ```
Enable easy usability on laravel, eg. using Façade, TypeHint, ?