Shuffle the current array.

@param bool  $secure <p>using a CSPRNG | @link https://paragonie.com/b/JvICXzh_jhLyt4y3</p>
@param array $array  [optional]

@return static
<p>(Immutable)</p>
496858
public function shuffle(bool $secure = false, array $array = null): self
    {
        if ($array === null) {
            $array = $this->getArray();
        }

        if ($secure !== true) {
            /** @noinspection NonSecureShuffleUsageInspection */
            \shuffle($array);
        } else {
            $size = \count($array, \COUNT_NORMAL);
            $keys = \array_keys($array);
            for ($i = $size - 1; $i > 0; --$i) {
                try {
                    $r = \random_int(0, $i);
                } catch (\Exception $e) {
                    /** @noinspection RandomApiMigrationInspection */
                    $r = \mt_rand(0, $i);
                }
                if ($r !== $i) {
                    $temp = $array[$keys[$r]];
                    $array[$keys[$r]] = $array[$keys[$i]];
                    $array[$keys[$i]] = $temp;
                }
            }

            // reset indices
            $array = \array_values($array);
        }

        foreach ($array as $key => $value) {
            // check if recursive is needed
            if (\is_array($value) === true) {
                $array[$key] = $this->shuffle($secure, $value);
            }
        }

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
1057411
public static function array_rand_values(array $array, $number)
    {
        if (!is_array($array)) {
            return array();
        }
        $array_keys = array_rand($array,$number);
        is_array($array_keys) ? null : $array_keys = array($array_keys);
        $index = 0;
        $arr_temp = array();
        foreach ( $array as $key => $row) {
            if (in_array($key, $array_keys,true)) {
                $arr_temp[$key] = $row;
                $index++;
            }
            if ($index >= $number) {
                unset($array);
                break;
            }
        }
        return $arr_temp;
    }
178634
public static <E> void shuffle(E[] array) {
		int swapPlace = -1;
		
		for(int i = 0; i < array.length; i++) {
            swapPlace = (int) (Math.random() * (array.length - 1 ));
            TrivialSwap.swap(array, i, swapPlace);
		}
	}
849048
public static function createFromArray(array $array): self
    {
        if (!isset($array['uuid'], $array['app_id'])) {
            throw InvalidFormatException::indexFormatNotValid();
        }

        return new self(
            IndexUUID::createFromArray($array['uuid']),
            AppUUID::createFromArray($array['app_id']),
            $array['is_ok'] ?? false,
            $array['doc_count'] ?? 0,
            $array['size'] ?? '0kb',
            $array['shards'] ?? Config::DEFAULT_SHARDS,
            $array['replicas'] ?? Config::DEFAULT_REPLICAS,
            $array['fields'] ?? [],
            $array['metadata'] ?? []
        );
    }
762582
protected function shuffleAssoc(&$array) 
    {
        $keys = array_keys($array);
        shuffle($keys);
        shuffle($keys);
    
        foreach($keys as $key) 
        {
            $new[$key] = $array[$key];
            unset($array[$key]); /* save memory */
        }
        $array = $new;
        
        return true;
    }
455008
public static void shuffle(long[] array) {
        for (int i = array.length - 1; i > 0; i--) {
            int j = Prng.nextInt(i + 1);
            // Swap array[i] and array[j]
            long tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
        }
    }
1267789
public static function kshuffle(&$array)
    {
        if (!is_array($array) || empty($array))
        {
            return false;
        }
        $tmp = [];
        foreach ($array as $key => $value)
        {
            $tmp[] = ['k' => $key, 'v' => $value];
        }
        shuffle($tmp);
        $array = [];
        foreach ($tmp as $entry)
        {
            $array[$entry['k']] = $entry['v'];
        }

        return true;
    }
183436
public static function createFromArray(array $array)
    {
        $scoreStrategy = new self();
        $scoreStrategy->type = $array['type'] ?: self::DEFAULT_TYPE;
        $scoreStrategy->configuration = $array['configuration'] ?? [];
        $scoreStrategy->weight = $array['weight'] ?? self::DEFAULT_WEIGHT;
        $scoreStrategy->scoreMode = $array['score_mode'] ?? self::SCORE_MODE_AVG;
        $scoreStrategy->filter = is_array($array['filter'])
            ? Filter::createFromArray($array['filter'])
            : null;

        return $scoreStrategy;
    }
1063507
public static function disaggregate($array)
    {
        $new = [];
        foreach ($array as $key => $val) {
            if (false !== strpos($key, ".")) {
                list($realKey, $aggregated) = explode(".", $key, 2);
                $values = self::getDisaggregatedValues(preg_grep("/^$realKey/", array_keys($array)), $array);
                $new[$realKey] = self::disaggregate($values);
            } else {
                $new[$key] = $val;
            }
        }

        return $new;
    }
1123098
protected function shuffle_assoc(&$array) {
        if (count($array) > 1) {
            // $keys needs to be an array, no need to shuffle 1 item or empty arrays, anyway
            $keys = array_keys($array);
            shuffle($keys);
            foreach($keys as $key) {
                $new[$key] = $array[$key];
            }
            $array = $new;
        }
        return true; // because this behaves like in-built shuffle(), which returns true
    }
492195
public function exchangeArray($array)
    {
        if (!empty($array['id'])) {
            $this->setId($array['id']);
        }
        $this->setTitulo($array['titulo']);
        if (isset($array['imagem']['tmp_name']) && !empty($array['imagem']['tmp_name'])) {
            $this->setImagem(basename($array['imagem']['tmp_name']));
        } elseif(isset($array['imagemAntiga'])) {
            $this->setImagem($array['imagemAntiga']);
        } else {
            $this->setImagem($array['imagem']);
        }
        unset($array['imagemAntiga']);
        $this->setDescricao($array['descricao']);
        $this->setPreco($array['preco']);
        return $this;
    }
1326300
public function copyFromArray(array &$array)
    {
        // parameters
        $this->setParameters(
            LanguageUtility::getFromArray('parameters', $array));

        // clientId
        $this->setClientId(
            LanguageUtility::getFromArray('clientId', $array));

        // clientSecret
        $this->setClientSecret(
            LanguageUtility::getFromArray('clientSecret', $array));
    }
1280222
private function cleanArray(array $array = [], $replaceWith)
    {
        $dirtyKeys = $this->findBadWordsInArray($array);

        foreach ($dirtyKeys as $key) {

            $this->cleanArrayKey($key, $array, $replaceWith);
        }

        return $array;
    }
1002384
public function fromArray(array $array, $clear = false)
  {
    if ($clear) {
      $this->vars = array();
    }

    foreach ($array as $key => $val) {
      $this->set($key, $val);
    }

    return $this;
  }
113473
public function copyFromArray(array &$array)
    {
        // ticket
        $this->setTicket(
            LanguageUtility::getFromArray('ticket', $array));

        // reason
        $this->setReason(
            AuthorizationFailReason::valueOf(
                LanguageUtility::getFromArray('reason', $array)));

        // description
        $this->setDescription(
            LanguageUtility::getFromArray('description', $array));
    }
922328
public static function js(array $array, $params = array(
        'attributes' => array(),
        'secure' => null
    ))
    {
        Arr::mergeWithDefaultParams($params);

        if (!$params['secure']) {
            try {
                $params['secure'] = Utils::isHTTPS();
            } catch (Exception $e) {

            }
        }

        $out = "\n";

        foreach($array as $key => $item){
            if(is_array($item)){
                $out .= Html::script($item[0], $item[1], $item[2])."\n";
            } else {
                $out .= Html::script($item, $params['attributes'] ?: [], $params['secure'])."\n";
            }
        }


        return $out;
    }
472476
public static function css(array $array , $params = array(
        'attributes' => [],
        'secure' => null
    ))
    {
        Arr::mergeWithDefaultParams($params);

        if (!$params['secure']) {
            try {
                $params['secure'] = Utils::isHTTPS();
            } catch (Exception $e) {

            }
        }

        $out = "\n";

        foreach($array as $key => $item){
            if(is_array($item)){
                $out .= Html::style($item[0], $item[1], $item[2])."\n";
            } else {
                $out .= Html::style($item, $params['attributes'], $params['secure'])."\n";
            }
        }

        return $out;
    }