Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

optional and boolean api inconsistency #513

Merged
merged 5 commits into from
Oct 12, 2015
Merged

optional and boolean api inconsistency #513

merged 5 commits into from
Oct 12, 2015

Conversation

EmanueleMinotto
Copy link
Contributor

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

@@ -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.
Copy link
Owner

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.

@EmanueleMinotto
Copy link
Contributor Author

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
Copy link
Owner

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 ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, sorry

@fzaninotto
Copy link
Owner

Needs rebase

@EmanueleMinotto
Copy link
Contributor Author

@fzaninotto sorry for the months of delay, I hope it isn't too late

@EmanueleMinotto
Copy link
Contributor Author

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)
Copy link
Owner

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?

@fzaninotto
Copy link
Owner

It' been open for too long, time to merge!

fzaninotto added a commit that referenced this pull request Oct 12, 2015
optional and boolean api inconsistency
@fzaninotto fzaninotto merged commit f1c0da2 into fzaninotto:master Oct 12, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants