public function random(int $number = 1, ?string $key = null)
    {
        $value = $this->get($key);

        if (is_array($value)) {
            $keys = array_keys($value);
            $keysLength = count($keys);

            shuffle($keys);

            if ($number > $keysLength) {
                $number = $keysLength;
            }

            for ($result = [], $count = 0; $count < $number; $count++) {
                $result[$keys[$count]] = $value[$keys[$count]];
            }

            return count($result) > 1 ? $result : current($result);
        }

        return $value;
    }
public function random(int $number = 1, ?string $key = null)
    {
        $value = $this->get($key);

        if (is_array($value)) {
            $keys = array_keys($value);
            $keysLength = count($keys);

            shuffle($keys);

            if ($number > $keysLength) {
                $number = $keysLength;
            }

            for ($result = [], $count = 0; $count < $number; $count++) {
                $result[$keys[$count]] = $value[$keys[$count]];
            }

            return count($result) > 1 ? $result : current($result);
        }

        return $value;
    }
public function random ( int $ number = 1 , ? string $ key = null ) { $ value = $ this -> get ( $ key ) ; if ( is_array ( $ value ) ) { $ keys = array_keys ( $ value ) ; $ keysLength = count ( $ keys ) ; shuffle ( $ keys ) ; if ( $ number > $ keysLength ) { $ number = $ keysLength ; } for ( $ result = [ ] , $ count = 0 ; $ count < $ number ; $ count ++ ) { $ result [ $ keys [ $ count ] ] = $ value [ $ keys [ $ count ] ] ; } return count ( $ result ) > 1 ? $ result : current ( $ result ) ; } return $ value ; }
Gets random value.

@param int         $number
@param string|null $key

@return mixed
Gets random value .