[10.x] Add Conditionable
and Macroable
traits to Sleep
#47092
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the new release of
Sleep
you can easily interface with the sleeping mechanism of PHP, which is great! A few areas we could improve this:Conditionables
One thing it lacks is the ability to conditionally define (or override) the time to sleep (TTS?), which could be easily achieved using the
Illuminate\Support\Conditionable
trait. For a rudimentary example:Macros
Another thing it lacks is the ability to define reusable macros to override or supplement the TTS. This could be very helpful if you application sleeps in various places and you want standardised sleep logic, or wish to leverage a database setting (perhaps user-defined) to control the sleep. For a rudimentary example:
Replacing durations
To supplement both of the aforementioned features, the ability to replace the previously defined duration would be helpful, so this has been added as well. For example:
Happy to rename this to
->set()
or->replace()
or whatever.While these changes might not seem immediately useful or crucial to all, I foresee them being helpful to people writing elegant sleep rules.