<commit_before><?php
namespace wcf\util;

/**
 * Contains Array-related functions.
 *
 * @author 	<NAME>
 * @copyright	2001-2009 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	util
 * @category 	Community Framework
 */
class ArrayUtil {
	/**
	 * Applies StringUtil::trim() to all elements of an array.
	 *
	 * @param 	array 		$array
	 * @param 	boolean		$removeEmptyElements
	 * @return 	array 		$array
	 */
	public static function trim($array, $removeEmptyElements = true) {
		if (!is_array($array)) {
			return StringUtil::trim($array);
		}
		else {
			foreach ($array as $key => $val) {
				$temp = self::trim($val, $removeEmptyElements);
				if ($removeEmptyElements && empty($temp)) unset($array[$key]);
				else $array[$key] = $temp;
			}
			return $array;
		}
	}
	
	/**
	 * Applies intval() to all elements of an array.
	 *
	 * @param 	array 		$array
	 * @return 	array 		$array
	 */
	public static function toIntegerArray($array) {
		if (!is_array($array)) {
			return intval($array);
		}
		else {
			foreach ($array as $key => $val) {
				$array[$key] = self::toIntegerArray($val);
			}
			return $array;
		}
	}
	
	/**
	 * Converts html special characters in arrays.
	 *
	 * @param 	array 		$array
	 * @return 	array 		$array
	 */
	public static function encodeHTML($array) {
		if (!is_array($array)) {
			return StringUtil::encodeHTML($array);
		}
		else {
			foreach ($array as $key => $val) {
				$array[$key] = self::encodeHTML($val);
			}
			return $array;
		}
	}
	
	/**
	 * Applies stripslashes on all elements of an array.
	 *
	 * @param 	array 		$array
	 * @return 	array 		$array
	 */
	public static function stripslashes($array) {
		if (!is_array($array)) {
			return stripslashes($array);
		}
		else {
			foreach ($array as $key => $val) {
				$array[$key] = self::stripslashes($val);
			}
			return $array;
		}
	}
	
	/**
	 * Appends a suffix to all elements of the given array.
	 *
	 * @param	array	 $array
	 * @param	string	 $suffix
	 * @return 	array
	 */
	public static function appendSuffix($array, $suffix) {
		foreach ($array as $key => $value) {
			$array[$key] = $value . $suffix;
		}
		
		return $array;
	}
	
	/**
	 * Computes the intersection of arrays using keys for comparison
	 * Alias to php array_intersect_key() function
	 *
	 * @param 	array 	$array1 	The array with master keys to check. 
	 * @param 	array 	$array2		An array to compare keys against.
	 * @return 				Returns an associative array containing all the values of array1  which have matching keys that are present in all arguments. 
	 * @see					array_intersect_key
	 */
	public static function intersectKeys($array1, $array2) {
		if (!function_exists('array_intersect_key')) {
			$numberOfArguments = func_num_args();
			for ($i = 1; !empty($array1) && $i < $numberOfArguments; $i++) {
	        		$currentArray = func_get_arg($i);
				foreach (array_keys($array1) as $key) {
					if (!isset($currentArray[$key])) {
						unset($array1[$key]);
					}
				}
			}
			return $array1;
		} 
		else {
			$parameters = func_get_args();
			return call_user_func_array('array_intersect_key', $parameters);
		}
	}
	
	/**
	 * Converts dos to unix newlines.
	 *
	 * @param 	array 		$array
	 * @return 	array 		$array
	 */
	public static function unifyNewlines($array) {
		if (!is_array($array)) {
			return StringUtil::unifyNewlines($array);
		}
		else {
			foreach ($array as $key => $val) {
				$array[$key] = self::unifyNewlines($val);<commit_msg>Removed ArrayUtil::intersectKeys()<commit_after><?php
namespace wcf\util;

/**
 * Contains Array-related functions.
 *
 * @author 	<NAME>
 * @copyright	2001-2009 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	util
 * @category 	Community Framework
 */
class ArrayUtil {
	/**
	 * Applies StringUtil::trim() to all elements of an array.
	 *
	 * @param 	array 		$array
	 * @param 	boolean		$removeEmptyElements
	 * @return 	array 		$array
	 */
	public static function trim($array, $removeEmptyElements = true) {
		if (!is_array($array)) {
			return StringUtil::trim($array);
		}
		else {
			foreach ($array as $key => $val) {
				$temp = self::trim($val, $removeEmptyElements);
				if ($removeEmptyElements && empty($temp)) unset($array[$key]);
				else $array[$key] = $temp;
			}
			return $array;
		}
	}
	
	/**
	 * Applies intval() to all elements of an array.
	 *
	 * @param 	array 		$array
	 * @return 	array 		$array
	 */
	public static function toIntegerArray($array) {
		if (!is_array($array)) {
			return intval($array);
		}
		else {
			foreach ($array as $key => $val) {
				$array[$key] = self::toIntegerArray($val);
			}
			return $array;
		}
	}
	
	/**
	 * Converts html special characters in arrays.
	 *
	 * @param 	array 		$array
	 * @return 	array 		$array
	 */
	public static function encodeHTML($array) {
		if (!is_array($array)) {
			return StringUtil::encodeHTML($array);
		}
		else {
			foreach ($array as $key => $val) {
				$array[$key] = self::encodeHTML($val);
			}
			return $array;
		}
	}
	
	/**
	 * Applies stripslashes on all elements of an array.
	 *
	 * @param 	array 		$array
	 * @return 	array 		$array
	 */
	public static function stripslashes($array) {
		if (!is_array($array)) {
			return stripslashes($array);
		}
		else {
			foreach ($array as $key => $val) {
				$array[$key] = self::stripslashes($val);
			}
			return $array;
		}
	}
	
	/**
	 * Appends a suffix to all elements of the given array.
	 *
	 * @param	array	 $array
	 * @param	string	 $suffix
	 * @return 	array
	 */
	public static function appendSuffix($array, $suffix) {
		foreach ($array as $key => $value) {
			$array[$key] = $value . $suffix;
		}
		
		return $array;
	}
	
	/**
	 * Converts dos to unix newlines.
	 *
	 * @param 	array 		$array
	 * @return 	array 		$array
	 */
	public static function unifyNewlines($array) {
		if (!is_array($array)) {
			return StringUtil::unifyNewlines($array);
		}
		else {
			foreach ($array as $key => $val) {
				$array[$key] = self::unifyNewlines($val);
{'fraction_non_alphanumeric': 0.14788273615635178, 'fraction_numerical': 0.004234527687296417, 'mean_word_length': 3.1076923076923078, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3133557', 'n_tokens_mistral': 2436, 'n_tokens_neox': 2073, 'n_words': 543}