[5.4] array_random helper - #19741
Merged
Merged
Conversation
tillkruss
reviewed
Jun 23, 2017
| { | ||
| return $array[array_rand($array)]; | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
We should probably support the optional $num argument as well.
Contributor
There was a problem hiding this comment.
Indeed, the $num argument should be supported.
Contributor
There was a problem hiding this comment.
Also, just as a proposal: in addition to the regular "raffle tickets" mode, a "dice roll" mode might be added, allowing items to be picked several times. (see fzaninotto/Faker#1060 to better understand what I mean)
|
Nice work! And what about docs? The are few functions in src/Illuminate/Support/helpers.php, but not in the docs. Or will documentation be updated with laravel 5.5? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I know helper functions are unlikely to be pulled in, but figured I'd at least mention this. (I did include a usage of this helper in the framework FWIW)
I use this personally (especially in testing contexts).
The all to common pattern that makes me feel a little bit bad every time:
same thing with new helper:
much cleaner IMO - let's see what you think though
Thanks as always!