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