-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allows passing an enum
to randomElement()
or randomElements()
#620
allows passing an enum
to randomElement()
or randomElements()
#620
Conversation
randomElement()
or randomElements()
randomElement()
or randomElements()
enum
to randomElement()
or randomElements()
@localheinz is there I need to do with the failing pipeline items? The Didn't look into the \Traversable thing too closely. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify this a bit, but it looks good to me otherwise!
Thanks @localheinz! |
eea2bd5
to
f58c881
Compare
src/Faker/Provider/Base.php
Outdated
@@ -192,6 +192,10 @@ public static function randomElements($array = ['a', 'b', 'c'], $count = 1, $all | |||
$traversables = []; | |||
$arr = $array; | |||
|
|||
if (is_string($array) && function_exists('enum_exists') && enum_exists($array)) { | |||
$traversables = $array::cases(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we change this to $arr = $traversables = $array::cases()
the test passes, but I'm still unsure why it was failing in the first place
I find the code hard to understand in the first place and I am trying to clean it up in #639! |
2f21b41
to
3ac0b61
Compare
Co-authored-by: Andreas Möller <[email protected]>
Co-authored-by: Andreas Möller <[email protected]>
splits tests, splits phases of tests, adds more specific assertions Co-authored-by: Andreas Möller <[email protected]>
Co-authored-by: Andreas Möller <[email protected]>
5460815
to
021e8d3
Compare
Thank you, @cosmastech! |
What is the reason for this PR?
is fine, but I think it would be even nicer to have
Author's checklist
Traversable
s andEnum
s fakerphp.github.io#85Summary of changes
Review checklist