Cleans up $toDecode keys & values.

@param array $toDecode

@return array
188059
protected function cleanupEncoding(array $toDecode)
    {
        $decodedParams = [];
        foreach ($toDecode as $key => $value) {
            $decodedValue = \is_array($value) ? $this->cleanupEncoding($value) : (mb_check_encoding($value, 'UTF-8') ? $value : utf8_encode($value));
            $decodedParams[mb_check_encoding($key, 'UTF-8') ? $key : utf8_encode($key)] = $decodedValue;
        }

        return $decodedParams;
    }
1199150
private function cleanPost()
    {
        $this->post = $_POST;
        // Sanitize global data
        if (is_array($_POST)) {
            foreach ($_POST as $key => $value) {
                $_POST[$this->cleanKeys($key)] = $this->sanitize($value);
            }
        } else {
            $_POST = [];
        }

        return $_POST;
    }
238174
protected function _cleanupData(array $data = array())
    {
        $clean = array();

        foreach ($data as $key => $value)
        {
            if (!empty($value)) {
                $clean[$key] = $value;
            }
        }

        return $clean;
    }
1056230
private function removeValuesWithPasswordKeys($array, &$passwordRemoved = false)
    {
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $value = $this->removeValuesWithPasswordKeys($value, $removedChild);
                if ($removedChild) {
                    $array[$key] = $value;
                    $passwordRemoved = true;
                }
            } else {
                foreach ($this->auditRequestIgnoreKeys as $ignoreKey) {
                    if (stripos($key, $ignoreKey) !== false) {
                        $array[$key] = '*password removed*';
                        $passwordRemoved = true;
                        continue;
                    }
                }
            }
        }
        return $array;
    }
138109
public function getByCode($sCode)
    {
        $aLanguages = $this->getAll();
        return !empty($aLanguages[$sCode]) ? $aLanguages[$sCode] : false;
    }
945827
protected function cleanup(array &$data)
    {
        foreach ($data as &$value) {
            if (\is_array($value)) {
                $this->cleanup($value);
            }
        }

        $data = array_filter($data, function ($value) {
            return null !== $value;
        });
    }
266084
public static function clearNullValues(&$array)
    {
        foreach ($array as $key => &$value) {
            if (null === $value) {
                unset($array[$key]);
            } else if (is_array($value)) {
                self::clearNullValues($value);
                if (empty($value)) {
                    unset($array[$key]);
                }
            }
        }

        return $array;
    }
1102857
protected function getDeletedEventAttributes(): array
    {
        $old = [];

        foreach ($this->attributes as $attribute => $value) {
            if ($this->isAttributeAuditable($attribute)) {
                $old[$attribute] = $value;
            }
        }

        return [
            $old,
            [],
        ];
    }
549461
public static function cleanBeforeJson(array $array): array
    {
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $array[$key] = self::cleanBeforeJson($array[$key]);
            }

            if ($array[$key] === '' || null === $array[$key]) {
                unset($array[$key]);
            }
        }

        return $array;
    }
677787
protected function CleanupAffiliateCode($sAffiliateCode)
    {
        $sRet = '';
        $sAffiliateCode = trim($sAffiliateCode);
        if (!empty($sAffiliateCode)) {
            //get all rating services
            $sQuery = "  SELECT *
                       FROM `pkg_shop_rating_service`
                      WHERE `active` = '1'
                   ORDER BY `position`,`weight`  ASC
                  ";
            $oRatingServiceList = TdbPkgShopRatingServiceList::GetList($sQuery);
            $oRatingServiceList->GoToStart();

            //loop and try to identify one...
            while ($oService = $oRatingServiceList->Next()) {
                /* @var $oService TdbPkgShopRatingService */
                $pos = strpos($sAffiliateCode, strtolower(trim($oService->fieldAffiliateValue)));
                if (false !== $pos) {
                    //service found!
                    $oRatingServiceList->GoToEnd();
                    $sRet = $oService->fieldAffiliateValue;
                }
            }
        }

        return $sRet;
    }
847887
public static function dot_array($arrayDotted)
    {
        $array = array();
        foreach ($arrayDotted as $key => $value) {
            self::array_set($array, $key, $value);
        }
        return $array;
    }
714763
public function cleanArray(array $data)
    {
        $cleanedArray = [];

        foreach ($data as $key => $value) {
            $cleanedArray[$key] = \is_array($value)
                ? $this->cleanArray($value)
                : $this->getSafeArray($key, $data);
        }

        return $cleanedArray;
    }
339158
public static function cleanValue($value)
    {
        if (is_array($value)) {
            $new_value = [];

            foreach ($value as $k => $v) {
                $new_value[$k] = self::cleanValue($v);
            }

            return $new_value;
        }

        return stripslashes($value);
    }
1028846
private function cleanup()
    {
        if (isset($this->collection[$this->id_info])) {
            foreach ($this->collection[$this->id_info] as $key => $val) {
                $expire = $this->getSessionInfo($key, 'expire');
                if ($expire === true) {
                    $this->setSessionInfo($key, 'expire', -1);
                } elseif ($expire == -1) {
                    $this->delete($key);
                }
            }
        }
    }
715096
public function toDbValue($value)
    {
        if ($this->isString($value)) {
            return $this->quoteIfNecessary($value);
        }

        // smelly code. Refactor

        if ($value === true) {
            return 'TRUE';
        }

        if ($value === false) {
            return 'FALSE';
        }

        if ($value === null) {
            return 'NULL';
        }

        if (is_array($value)) {
            if (isset($value['value'])) {
                return $value['value'];
            }
        }

        return $value;
    }
672757
public function toData()
    {
        if ($this->action === self::TYPE_READ) {
            return [
                'fields' => 'whitelisted_domains',
            ];
        }

        if ($this->action === self::TYPE_DELETE) {
            return [
                'fields' => [
                    'whitelisted_domains',
                ],
            ];
        }

        return [
            'whitelisted_domains' => $this->domains,
        ];
    }
791224
protected function cleanValue($key, $value)
    {
        if (is_array($value)) {
            return $this->cleanArray($value);
        }

        return $this->transform($key, $value);
    }