| @@ 335-344 (lines=10) @@ | ||
| 332 | * |
|
| 333 | * @return mixed get a random value or null if there wasn't a value |
|
| 334 | */ |
|
| 335 | public function randomValue() |
|
| 336 | { |
|
| 337 | $result = $this->random(1); |
|
| 338 | ||
| 339 | if (!isset($result[0])) { |
|
| 340 | $result[0] = null; |
|
| 341 | } |
|
| 342 | ||
| 343 | return $result[0]; |
|
| 344 | } |
|
| 345 | ||
| 346 | /** |
|
| 347 | * alias: for "Arrayy->randomValues()" |
|
| @@ 390-399 (lines=10) @@ | ||
| 387 | * |
|
| 388 | * @throws \RangeException If array is empty |
|
| 389 | */ |
|
| 390 | public function randomKey() |
|
| 391 | { |
|
| 392 | $result = $this->randomKeys(1); |
|
| 393 | ||
| 394 | if (!isset($result[0])) { |
|
| 395 | $result[0] = null; |
|
| 396 | } |
|
| 397 | ||
| 398 | return $result[0]; |
|
| 399 | } |
|
| 400 | ||
| 401 | /** |
|
| 402 | * Pick a given number of random keys/indexes out of this array. |
|