Upgrade to 4.4.0

This commit is contained in:
Bastian Allgeier
2024-09-12 14:43:02 +02:00
parent a955c7822e
commit 8bc7250b68
87 changed files with 637 additions and 352 deletions

View File

@@ -738,12 +738,18 @@ class A
/**
* Returns a number of random elements from an array,
* either in original or shuffled order
*
* @throws \Exception When $count is larger than array length
*/
public static function random(
array $array,
int $count = 1,
bool $shuffle = false
): array {
if ($count > count($array)) {
throw new InvalidArgumentException('$count is larger than available array items');
}
if ($shuffle === true) {
return array_slice(self::shuffle($array), 0, $count);
}