Convert booleans to strings, removed unset parameters, and sorts the array

@param array $data Data array

@return array
773623
protected function prepareParameters($data)
    {
        ksort($data);
        foreach ($data as $key => &$value) {
            switch (gettype($value)) {
                case 'NULL':
                    unset($data[$key]);
                    break;
                case 'array':
                    $data[$key] = self::prepareParameters($value);
                    break;
                case 'boolean':
                    $data[$key] = $value ? 'true' : 'false';
                    break;
            }
        }

        return $data;
    }
413386
protected function stringArray(Array $data)
    {
        $str = EOL . HT . '[' . EOL;

        foreach( $data as $key => $val )
        {
            $str .= HT . HT . "'" . $key . "' => '" . $val . "'," . EOL;
        }

        $str  = Base::removeSuffix($str, ',' . EOL);
        $str .= EOL . HT . ']';

        return $str;
    }
829886
public function unredislizeArray(array $data)
    {
        $result = [];
        foreach ($data as $key => $value) {
            $result[$key] = $this->unredislize($value);
        }

        return $result;
    }
1296707
private static function unsetValues(array &$data, array &$removeValues)
    {
        foreach ($removeValues as $value) {
            $position = \array_search($value, $data);
            if ($position !== false) {
                unset($data[$position]);
            }
        }
        return $data;
    }
1239851
public function arraySerialize(array $Data)
    {
        $Result = "";
        foreach ($Data as $Value) {
            if ($Result == "") {
                $Result = floor($Value);
            } else {
                $Result = $Result . "," . floor($Value);
            }
        }

        return $Result;
    }
786906
protected function formatData($data=null)
    {
        if (!is_null($data)) {
            if (is_scalar($data)) {
                $data = ['id' => $data];
            }
        } else {
            $data = (array) $data;
        }
        
        foreach ($data as $k => $v) {
            if ($v == "" || is_bool($v)) {
                $data[$k] = intval($v);
            } elseif (is_numeric($v)) {
                $data[$k] = (strpos($v, '.') !== false) ? floatval($v) : intval($v);
            }
        }
        
        $data && ksort($data);
        
        return $data;
    }
1087463
private function normalizeArrayForNewLines(array $data) {
		foreach($data as $k => $item) {
			if(is_string($item)) {
				$data[$k] = str_replace(["\r\n", "\n\r", "\r"], "\n", $item);
			} elseif(is_array($item)) {
				$data[$k] = $this->normalizeArrayForNewLines($item);
			}
		}
		return $data;
	}
456479
public function serializeData($data) {
		if(is_array($data)) {
			ksort($data);
			$return = '';
			foreach($data as $key => $value) {
				if(is_numeric($key)) {
					$return .= $this->serializeData($value);
				} else {
					$return .= $key . $this->serializeData($value);
				}
			}
			return $return;
		} else {
			return (string)$data;
		}
	}
1153369
private function deserialize($data)
    {
        $result = json_decode(base64_decode($data, true), true);

        return is_array($result) ? $result : [];
    }
852434
protected function parseValues($data)
    {
    	if (isset($data[0])) {
    		$set = $this->_parseDataItemToValues($data);
    	} else {
    		$set = $this->parse($data);
    	}
        
        foreach ($set as $v) {
            $group[] = '(' . implode(',', $v) . ')';
        }
        return empty($set) ? '' : 'VALUES '. implode(',', $group);
    }
262558
protected static function filterValues(array $data)
    {
        $returnValue = array();
        foreach ($data as $d) {
            if ($d !== null) {
                $returnValue[] = $d->getValue();
            } else {
                $returnValue[] = $d;
            }
        }

        return $returnValue;
    }
872221
protected function _getData(array $data): array
    {
        // Stringify empty values
        if (!empty($data)) {
            foreach ($data as $fieldName => $value) {
                $data[$fieldName] = $this->_stringifyEmptyValue($value);
            }
        }

        return $data;
    }
1036926
public static function arrayColumns(array $data)
    {
        // Count the amount of values from the source input
        $count = count($data);

        if ($count === 0) {
            return false;
        }

        if ($count === 1) {
            return array_keys($data[0]);
        }

        if (isset($data[0])) {
            return array_keys($data[0]);
        } else {
            return false;
        }
    }
1205822
public function convertRenditions(array $data = null)
    {
        return array_filter(
            array_map(
                [$this, 'convertRendition'],
                array_filter(
                    $data,
                    'is_array'
                )
            ),
            function ($item) {
                // @TODO once a logger is available we should log an INFO message if the rendition could not be converted
                return !empty($item);
            }
        );
    }
613870
protected function encode(array $data)
    {

        foreach ($data as $key => $value) {
            if (is_string($value)) {
                $data[$key] = base64_encode($value);
            }
        }

        return $data;
    }
1213805
public static function encode($data)
    {
        $data = (array) $data;

        $resultString = self::loopEncode($data);

        return trim($resultString, PHP_EOL);
    }
166208
public function normalizeFormData(array $data)
    {
        if (empty($data)) {
            return $data;
        }

        $renameMap = array_flip($this->renamemap);

        foreach ($renameMap as $customName => $defaultName) {
            if (array_key_exists($customName, $data)) {
                $value = $data[$customName];
                unset($data[$customName]);
                $data[$defaultName] = $value;
            }
        }

        return $data;
    }