Giter Club home page Giter Club logo

Comments (7)

pimjansen avatar pimjansen commented on September 25, 2024 1

Ok thanks! We will update the docs accordingly

from faker.

pimjansen avatar pimjansen commented on September 25, 2024

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.

chinleung avatar chinleung commented on September 25, 2024

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.

pimjansen avatar pimjansen commented on September 25, 2024

Hmm its in the internal docblock. Can you confirm the suggestion works?

from faker.

chinleung avatar chinleung commented on September 25, 2024

Hmm its in the internal docblock. Can you confirm the suggestion works?

Ah I see. It works by passing a float.

from faker.

pimjansen avatar pimjansen commented on September 25, 2024

FakerPHP/fakerphp.github.io#39

from faker.

chinleung avatar chinleung commented on September 25, 2024

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.