Comments (7)
Ok thanks! We will update the docs accordingly
from faker.
As mentioned in the docs, if an int is provided it ranges from 0 to 100. So in your case 1/100 chance on the generator.
With a float it works from 0.00 to 1.00
from faker.
As mentioned in the docs, if an int is provided it ranges from 0 to 100. So in your case 1/100 chance on the generator.
With a float it works from 0.00 to 1.00
@pimjansen Can you link me to where it says it in the doc please? I can't seem to find it. Maybe I'm not looking at the right place but in https://fakerphp.github.io/#modifiers, I don't see the mention of int and float.
// optional() accepts a weight argument to specify the probability of receiving the default value.
// 0 will always return the default value; 1 will always return the provider. Default weight is 0.5 (50% chance).
$faker->optional($weight = 0.1)->randomDigit(); // 90% chance of NULL
$faker->optional($weight = 0.9)->randomDigit(); // 10% chance of NULL
from faker.
Hmm its in the internal docblock. Can you confirm the suggestion works?
from faker.
Hmm its in the internal docblock. Can you confirm the suggestion works?
Ah I see. It works by passing a float.
from faker.
FakerPHP/fakerphp.github.io#39
from faker.
@pimjansen Sorry! I just tested this again and I think when I tested with the float, I didn't do (float) 1
. When I pass a (float) 1
, it's always returning the default provider.
from faker.
Related Issues (20)
- Discuss branching model HOT 2
- Add property, parameter, and return type declarations HOT 1
- Declare strict types HOT 2
- Add PHP version support policy HOT 2
- Add package version support policy HOT 1
- Discuss release schedule HOT 2
- Drop support for PHP 7.4 HOT 4
- Update docs to reflect different major versions HOT 2
- Remove functionality for populating ORM models and entities HOT 1
- The output of the md5(), sha1() and sha256() generators is misleading HOT 4
- The output of Base::randomFloat() is biased for certain inputs
- The Miscellaneous::boolean() generator could take a random float instead of an integer
- Warning DEPRECATED use of static pt_BR PhoneNumber HOT 1
- Opinions on Providing a Fake for CIDR/IP Prefixes HOT 3
- Faker images links are broken HOT 6
- Unable to get any other text but Latin HOT 4
- E-commerce Plugin - Feature HOT 1
- [ru_RU/PersonProvider] Double `а` in female lastName when using the `name()` function HOT 3
- Feature Request: Adjective Animal HOT 2
- Issue when try to use the create() function in the class_exists, throws an error when the documentation says the the function should not returns error just bool value. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faker.