Code Monkey home page Code Monkey logo

factory-muffin-faker's Introduction

Factory Muffin Faker 2.3

StyleCI Status Build Status Software License Latest Version Total Downloads

The goal of this package is to wrap Faker to make it super easy to use with Factory Muffin.

Note that this library does not actually require Factory Muffin in order to work, so may be used else where too. The whole point of this library is to wrap Faker in closures so the actual generation can be executed at a later point.

Installing

PHP 5.4+ and Composer are required.

In your composer.json, simply add "league/factory-muffin-faker": "^2.3" to your "require-dev" section:

{
    "require-dev": {
        "league/factory-muffin-faker": "^2.3"
    }
}

Contributing

Please check out our contribution guidelines for details.

Credits

Factory Muffin Faker is a wrapper around Faker to make it super easy to use with Factory Muffin, and is currently maintained by Graham Campbell. Thank you to all our wonderful contributors too.

Security

If you discover a security vulnerability within this package, please send an email to Graham Campbell at [email protected]. All security vulnerabilities will be promptly addressed. You may view our full security policy here.

License

Factory Muffin Faker is licensed under The MIT License (MIT).

For Enterprise

Available as part of the Tidelift Subscription

The maintainers of league/factory-muffin-faker and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

factory-muffin-faker's People

Contributors

grahamcampbell avatar krsriq avatar maxmirazh33 avatar pfuhrmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

factory-muffin-faker's Issues

Keep compatibility with Faker

I really like FactoryMuffin 3.0. In my opinion a lot of good design decisions were made for the upcoming version.

What's a show stopper for me at the moment though is very limited compatibility with Faker through the facade. Especially bothering at the current point is one thing. If I'm using Faker directly I can concatenate generated string. So this would work

$fm->define('Model')->setDefinitions(array(
    'someValue' => $faker->firstName() . ' ' . $faker->randomNumber()
));

Using the facade I get an exception, because the returned closure can not be casted to a string.

$fm->define('Model')->setDefinitions(array(
    'someValue' => Faker::firstName() . ' ' . Faker::randomNumber()
));

That's why I'm wondering, why is a closure returned in Faker.php in line 121 (format() method). Why is the result not directly returned like so:

/**
     * Wrap a faker format in a closure.
     *
     * @param string $formatter The formatter.
     * @param array  $arguments The arguments.
     *
     * @return \Closure
     */
    public function format($formatter, array $arguments = [])
    {
        return $this->getGenerator()->format( $formatter, $arguments );
    }

This would already resolve the issue but I guess there would be other drawbacks?

I dosent install Faker 1.5

when I require the package with composer I figure out that the faker dependency still on 1.4, how I can get 1.5? because I need the Arabic support from faker 1.5 to to generate data!!

unique() doesn't scale

unique() is pretty easy to understand: a global repository of already-generated data, guaranteed not to be repeated. In our application, we have ~400 factories, and about 1k instances of unique() corresponding to database constraint and about 800 unit tests. We easily surpass the 10k limit and even when upping to 100k. It would be immensely helpful to be able to pass a key: unique('table.column')->whatever(). In addition, would be good to have a clear() method when we refresh the database.

protected function _after()
{
    Faker::unique()->clear();
}

If agreed, I can spin up a PR.

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.