src/Bag.php
public function randomKeys($size)
    {
        Assert::notEmpty($this->items, 'Cannot retrieve a random key/value for empty bags.');
        Assert::range($size, 1, $this->count(), 'Expected $size to be between 1 and %3$s (the number of items in the bag). Got: %s');

        return $this->createFrom((array) array_rand($this->items, $size));
    }
public function randomKeys($size)
    {
        Assert::notEmpty($this->items, 'Cannot retrieve a random key/value for empty bags.');
        Assert::range($size, 1, $this->count(), 'Expected $size to be between 1 and %3$s (the number of items in the bag). Got: %s');

        return $this->createFrom((array) array_rand($this->items, $size));
    }
public function randomKeys ( $ size ) { Assert :: notEmpty ( $ this -> items , 'Cannot retrieve a random key/value for empty bags.' ) ; Assert :: range ( $ size , 1 , $ this -> count ( ) , 'Expected $size to be between 1 and %3$s (the number of items in the bag). Got: %s' ) ; return $ this -> createFrom ( ( array ) array_rand ( $ this -> items , $ size ) ) ; }
Returns a list with a random number of keys (as values).

@param int $size Number of keys

@throws \InvalidArgumentException when the bag is empty or the given $size is greater than the number of items

@return static
Returns a list with a random number of keys ( as values ) .