-
Notifications
You must be signed in to change notification settings - Fork 3.6k
optional and boolean api inconsistency #513
Conversation
@@ -292,6 +292,16 @@ $faker->optional($weight = 0.5, $default = false)->randomDigit; // 50% chance of | |||
$faker->optional($weight = 0.9, $default = 'abc')->word; // 10% chance of 'abc' | |||
``` | |||
|
|||
Since v1.5 this method will accept a percentage like the `boolean()` method. |
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 you should just replace the old doc with the new preferred way, which is the integer way. As for the BC break, it's very minimal. I'll just mention it in the release post.
Done, let me know if anything else is required |
@@ -945,6 +945,7 @@ echo $faker->cityName; | |||
* [AliceFixturesBundle](https://github.com/h4cc/AliceFixturesBundle): A Symfony2 bundle for using Alice and Faker with data fixtures. Abled to use Doctrine ORM as well as Doctrine MongoDB ODM. | |||
* [Factory Muffin](https://github.com/thephpleague/factory-muffin): enable the rapid creation of objects (PHP port of factory-girl) | |||
* [CompanyNameGenerator](https://github.com/fzaninotto/CompanyNameGenerator): Generate names for English tech companies with class | |||
* [PlaceholdItProvider](https://github.com/EmanueleMinotto/PlaceholdItProvider): Generate images using placehold.it |
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.
Pirate change. Requires another PR ;)
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.
You're right, sorry
Needs rebase |
I’m submitting this just to add it to the third-party libraries list
@fzaninotto sorry for the months of delay, I hope it isn't too late |
ping @fzaninotto |
* "0" will always return null, "1" will always return the generator. | ||
* If $weight is an integer value, then the same system works | ||
* between 0 (always get false) and 100 (always get true). | ||
* @return mixed|null | ||
*/ | ||
public function optional($weight = 0.5, $default = null) |
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.
shouldn't you make the default weight 50 to reflect the new system?
It' been open for too long, time to merge! |
optional and boolean api inconsistency
This PR if for #265.
I'm not 100% sure that the documentation is enough, let me know how to edit it if it isn't good.
Thanks