Helper method to convert an amount field to euros.

@param array $array
@param string $key
@param float $conversionRate

@return bool
Whether the amount was converted.
964438
public function convertAmount(array &$array, $key, $conversionRate)
    {
        if (!empty($array[$key]) && !empty($conversionRate)) {
            $array[$key] = (float) $array[$key] / (float) $conversionRate;
            return true;
        }
        return false;
    }
868740
public static function average($array = false, $decimals = 2) {

        if($array && Validate::isArray($array)) {

            return self::round((array_sum($array) / count($array)), $decimals); 
        }

        return false;
    }
1135350
public static function ksortRecursive(&$array, $sortFlags = SORT_REGULAR) {
		if (!is_array($array)) {
			return false;
		}

		ksort($array, $sortFlags);
		foreach ($array as &$arr) {
			static::ksortRecursive($arr, $sortFlags);
		}

		return true;
	}
236260
public static function max($array = false, $decimals = 3) {

        if($array && Validate::isArray($array)) {

            return self::round(max($array), $decimals);
        }

        return false;
    }
380596
public function toArray($set = [], $convert = true) {

		$methods = get_class_methods($this);
		$array 	 = [];

		if(true === is_string($set)) {
			$set = [$set];
		}

		$set 	= array_flip($set);
		$amount = count($set);

		foreach($methods as $method) {
			
			$chunks = explode('get', $method);

			if(count($chunks) == 2) {

				$key = (true === $convert) ? strtolower($chunks[1]) : $chunks[1];

				if($amount === 0 || ($amount > 0 && true === isset($set[$key]))) {

					$value = call_user_func_array([$this, $method], []);

					if($value instanceof Container) {
						$value = $value -> all();
					}

					if(0 === strlen(trim($key)) && ($value === null || 0 === strlen(trim($value)))) {
						continue;
					}

					$array[$key] = $value;
				}
			}
		}
		
		return json_decode(json_encode($array), true);
	}
1268883
private function camelizeKeys(array $array)
    {
        $camelized = array();

        foreach ($array as $key => $value) {
            $camelized[$this->camelize($key)] = is_array($value)
                ? $this->camelizeKeys($value)
                : $value;
        }

        return $camelized;
    }
737309
protected function setAmountsPrecision($array)
    {
        $amounts = explode(',', str_replace(' ', '', $array['amounts']));
        unset($array['amounts']);
        $temp = [];

        try {
            foreach ($amounts as $amount) {
                $temp[] = bcadd($amount, '0', 8);
            }

            return array_merge(
                        ['amounts' => implode(',', array_values($temp))],
                        $array
                    );
        } catch (Exception $e) {
            $e->getMessage();
        }
    }
1295212
public function getArrayValue(array $array, string $key)
    {
        foreach ($this->getBoth($key) as $loopKey) {
            if (array_key_exists($loopKey, $array)) {
                return $array[$loopKey];
            }
        }
    }
1281462
public static function ksortRecursive(&$array)
    {
        if (!is_array($array)) {
            return false;
        }

        ksort($array);
        foreach ($array as $key => $value) {
            static::ksortRecursive($array[$key]);
        }

        return true;
    }
1159773
public static function reduceToElementsWithKey($array, $key) {

        if ($array instanceof AssociativeArray) {
            $array = $array->toArray();
        }

        $targetArray = array();

        foreach ($array as $itemKey => $value) {

            if ($itemKey == $key) {
                $targetArray[$key] = $value;
            } else if (is_array($value) || $value instanceof AssociativeArray) {
                $subArray = ArrayUtils::reduceToElementsWithKey($value, $key);
                if (sizeof($subArray) > 0) {
                    $targetArray[$itemKey] = $subArray;
                }
            }

        }

        return $targetArray;

    }
78089
protected function convert_to_bool( $data, $key ) {
		return ! empty( $data[ $key ] ) && $data[ $key ] !== '0' && $data[ $key ] !== 'false';
	}
584933
public static function removeValue(&$array, $key, $default = null)
    {
        if (is_array($array)) {
            $value = static::getValue($array, $key, $default);
            unset($array[$key]);
            return static::value($value);
        }
        return self::value($default);
    }
446677
protected function exchangeRateCalculate($rate, $amount)
    {
        // code
        $conv = $amount * $rate;
        $resque = round($conv, 2);
        return $resque;
    }
792143
public static function sortByKey($array, $key, $useDotSyntax = false)
    {
        uasort($array, function ($a, $b) use ($key, $useDotSyntax) {
            $valueA = self::get($a, $key, null, $useDotSyntax);
            $valueB = self::get($b, $key, null, $useDotSyntax);
            if ($valueA == $valueB) {
                return 0;
            }

            return ($valueA < $valueB) ? -1 : 1;
        });

        return $array;
    }
227924
public static function isSupported($encoding, $convertEncoding = null)
    {
        $supportedEncodings = static::getSupportedEncodings();

        if (!in_array(strtoupper($encoding), $supportedEncodings)) {
            return false;
        }

        if ($convertEncoding !== null && !in_array(strtoupper($convertEncoding), $supportedEncodings)) {
            return false;
        }

        return true;
    }
901737
private function convertField($array)
    {
        $result = [];

        // Copy over well known keys.
        foreach (static::$convertFields as $key) {
            if (isset($array[$key])) {
                $result[$key] = $array[$key];
            }
        }

        if (isset($array['dataType'])) {
            $result['dataType'] = $this->inferType($array['dataType']);
        } else {
            $result['dataType'] = isset($array['children']) ? 'object' : DataTypes::STRING;
        }

        $result['required'] = isset($array['required']) && (bool) $array['required'];
        $result['readonly'] = isset($array['readonly']) && (bool) $array['readonly'];

        $result = $this->convertChildren($array, $result);

        return $result;
    }
755059
public function convertFixedRate(array $fixedExchange, int $amount, string $swift_code): MoneyPHP
    {
        return (new Converter(
            new ISOCurrencies(),
            (new ReversedCurrenciesExchange(new FixedExchange($fixedExchange)))
        ))->convert($this->castMoney($amount), new Currency($swift_code));
    }