| @@ 319-328 (lines=10) @@ | ||
| 316 | * |
|
| 317 | * @return mixed get a random value or null if there wasn't a value |
|
| 318 | */ |
|
| 319 | public function randomValue() |
|
| 320 | { |
|
| 321 | $result = $this->random(1); |
|
| 322 | ||
| 323 | if (!isset($result[0])) { |
|
| 324 | $result[0] = null; |
|
| 325 | } |
|
| 326 | ||
| 327 | return $result[0]; |
|
| 328 | } |
|
| 329 | ||
| 330 | /** |
|
| 331 | * alias: for "Arrayy->randomValues()" |
|
| @@ 374-383 (lines=10) @@ | ||
| 371 | * |
|
| 372 | * @throws \RangeException If array is empty |
|
| 373 | */ |
|
| 374 | public function randomKey() |
|
| 375 | { |
|
| 376 | $result = $this->randomKeys(1); |
|
| 377 | ||
| 378 | if (!isset($result[0])) { |
|
| 379 | $result[0] = null; |
|
| 380 | } |
|
| 381 | ||
| 382 | return $result[0]; |
|
| 383 | } |
|
| 384 | ||
| 385 | /** |
|
| 386 | * Pick a given number of random keys/indexes out of this array. |
|