1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-04-19 23:12:01 +02:00

randomElement accepts an array (#1993)

This commit is contained in:
Reed Jones 2020-10-23 00:12:00 -07:00 committed by GitHub
parent 29e7df18de
commit 74f8b2ec6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -387,7 +387,7 @@ print_r($values); // [0, 4, 8, 4, 2, 6, 0, 8, 8, 6]
// just like unique(), valid() throws an overflow exception when it can't generate a valid value
$values = array();
try {
$faker->valid($evenValidator)->randomElement(1, 3, 5, 7, 9);
$faker->valid($evenValidator)->randomElement([1, 3, 5, 7, 9]);
} catch (\OverflowException $e) {
echo "Can't pick an even number in that set!";
}