Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random helpers #5

Merged
merged 2 commits into from
Jun 17, 2020
Merged

Random helpers #5

merged 2 commits into from
Jun 17, 2020

Conversation

kbond
Copy link
Member

@kbond kbond commented Jun 16, 2020

Enables the following helpers:

repository(Post::class)->random(); // random Post
repository(Post::class)->randomSet(3); // 3 random Post's
repository(Post::class)->randomSet(0, 5); // 0-5 random Post's

PostFactory::random(); // random Post
PostFactory::randomSet(3); // 3 random Post's
PostFactory::randomSet(0, 5); // 0-5 random Post's

@kbond kbond mentioned this pull request Jun 16, 2020
24 tasks
README.md Outdated
@@ -591,6 +594,8 @@ use Zenstruck\Foundry\Proxy;

/**
* @method static Post|Proxy findOrCreate(array $attributes)
* @method static Post|Proxy random()
* @method static Post|Proxy randomSet(int $min, ?int $max = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

documenting this is tricky because randomSet(5) means "give me 5", so it's not a $min in that situation. I'm not sure exactly what to call it though - that method really wears two hats. I'm also not sure if we split it into 2 separate methods, what each would be called.

Also, this would return Post[]|Proxy[]

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm also not sure if we split it into 2 separate methods, what each would be called.

Yeah... randomSet() and randomRange()?

Also, this would return Post[]|Proxy[]

Ahh, good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants