Convert Countries

@since 2.1.0
@access private
@param array $array
@return array
169745
private function convertCountries($array)
    {
        $return = array();
        foreach ($array as $value) {
            array_push($return, array(
                'CountryCode' => $value->CountryCode,
                'MinimumAmount' => $value->MinimumAmount,
                'MaximumAmount' => $value->MaximumAmount,
                'Currencies' => $this->convertCurrencies($value->Currency)
            ));
        }
        return $return;
    }
143429
protected function flatten($array)
    {
        return array_reduce($array, function ($result, $item) {
            if (! is_array($item)) {
                return array_merge($result, [$item]);
            }

            return array_merge($result, $this->flatten($item));
        }, []);
    }
640184
static public function toLowerCaseKey(array $array)
	{
	    $res = [];
	    if ($array) {
	        foreach ($array as $k  => $v) {
	            if (is_array($v)) {
	                $v = static::toLowerCaseKey($v);
	            }
	            $res[strtolower($k)] = $v;
	        }
	    }
	    return $res;
	}
260471
public function flatter($array)
    {
        $result = [];
        foreach ($array as $item) {
            if (is_array($item)) {
                $result = array_merge($result, $this->flatter($item));
            } else {
                $result[] = $item;
            }
        }

        return $result;
    }
409524
public function packMap(array $array)
    {
        $size = count($array);
        $b = '';
        $b .= $this->getMapSizeMarker($size);

        foreach ($array as $k => $v) {
            $b .= $this->pack($k);
            $b .= $this->pack($v);
        }

        return $b;
    }
1035574
public static function typeCast(array $array)
    {
        $return = [];
        
        foreach ($array as $k => $v) {
            if (is_numeric($v)) {
                $return[$k] = StringHelper::typeCastNumeric($v);
            } elseif (is_array($v)) {
                $return[$k] = self::typeCast($v);
            } else {
                $return[$k] = $v;
            }
        }
        
        return $return;
    }
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;
    }
471507
private function rksort(array $array)
    {
        ksort($array);
        foreach ($array as $k => $v) {
            if (is_array($v)) {
                $array[$k] = $this->rksort($v);
            }
        }
        return $array;
    }
251987
static public function normaliseValues($array) {
		$array=self::arrayize($array);
		if (!$array) return $array;
		$minValue=min($array);
		$maxValue=max($array);
		if ($maxValue==$minValue) {
			$minValue-=1;
		}
		foreach($array as $index=>$value) {
			$array[$index]=($value-$minValue)/($maxValue-$minValue);
		}
		return $array;
	}
1296615
public function copyFromArray(array &$array)
    {
        // formatted
        $this->setFormatted(
            LanguageUtility::getFromArray('formatted', $array));

        // street_address
        $this->setStreetAddress(
            LanguageUtility::getFromArray('street_address', $array));

        // locality
        $this->setLocality(
            LanguageUtility::getFromArray('locality', $array));

        // region
        $this->setRegion(
            LanguageUtility::getFromArray('region', $array));

        // postal_code
        $this->setPostalCode(
            LanguageUtility::getFromArray('postal_code', $array));

        // country
        $this->setCountry(
            LanguageUtility::getFromArray('country', $array));
    }
1059742
public function toMappedArray(array $array)
    {
        $mappedArray = [];
        foreach ($this->getMapper() as $from => $to) {
            $mappedArray[$to] = $array[$from];
        }
        return $mappedArray;
    }
1012481
static public function sortByKeyRecursive(array $array)
    {
        ksort($array);
        foreach ($array as $key => $value) {
            if (is_array($value) && !empty($value)) {
                $array[$key] = self::sortByKeyRecursive($value);
            }
        }

        return $array;
    }
1057578
private function getArrayValues($array)
    {
        $out = [];
        $it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array));

        foreach ($it as $value) {
            $out[] = $value;
        }
        return $out;
    }
880218
public function flattenArray($array)
    {
        $result = [];
        foreach (array_dot($array) as $key => $value) {
            $splitKey = explode('.', $key);
            $newKey = $this->createArrayKey($splitKey);
            $result = array_merge($result, [$newKey => $value]);
        }

        return $result;
    }
231500
public function copyToArray(array &$array)
    {
        $array['grantType']            = LanguageUtility::toString($this->grantType);
        $array['clientId']             = LanguageUtility::orZero($this->clientId);
        $array['subject']              = $this->subject;
        $array['scopes']               = $this->scopes;
        $array['accessTokenDuration']  = LanguageUtility::orZero($this->accessTokenDuration);
        $array['refreshTokenDuration'] = LanguageUtility::orZero($this->refreshTokenDuration);
        $array['properties']           = LanguageUtility::convertArrayOfArrayCopyableToArray($this->properties);
        $array['clientIdAliasUsed']    = $this->clientIdAliasUsed;
        $array['accessToken']          = $this->accessToken;
        $array['refreshToken']         = $this->refreshToken;
    }
271241
public static function transpose(array $array): array
    {
        $new   = [];
        $keys  = array_keys($array);

        foreach ($keys as $k => $val) {
            foreach ((array) $array[$val] as $k2 => $v2) {
                $new[$k2][$val] = $v2;
            }
        }

        return $new;
    }
934371
public static function normalizeMap($array)
    {
        $nested = array();

        foreach ((array) $array as $key=>$value) {
            if (is_numeric($key)) {
                $nested[$value] = array();
            } else {
                $nested[$key] = $value;
            }
        }

        return $nested;
    }