<commit_before><?php

/**
 * Get all files in directory.
 *
 * @param  string $directory
 *
 * @return string
 */
function papi_get_all_files_in_directory( $directory = '' ) {
	$result = [];

	if ( empty( $directory ) || ! is_string( $directory ) ) {
		return $result;
	}

	if ( $handle = opendir( $directory ) ) {
		while ( false !== ( $file = readdir( $handle ) ) ) {
			if ( ! in_array( $file, ['..', '.'] ) ) {
				if ( is_dir( $directory . '/' . $file ) ) {
					$result   = array_merge( $result, papi_get_all_files_in_directory( $directory . '/' . $file ) );
				} else {
					$file     = $directory . '/' . $file;
					$result[] = preg_replace( '/\/\//si', '/', $file );
				}
			}
		}

		closedir( $handle );
	}

	return $result;
}

/**
 * Get core type file path, this allows classes to be overridden.
 *
 * @param  string $file_path
 *
 * @return string
 */
function papi_get_core_type_file_path( $file_path ) {
	if ( empty( $file_path ) ) {
		return [];
	}

	$directories = papi_filter_settings_directories();
	$result      = [];<commit_msg>Fix warning error when directory don't exists<commit_after><?php

/**
 * Get all files in directory.
 *
 * @param  string $directory
 *
 * @return string
 */
function papi_get_all_files_in_directory( $directory = '' ) {
	$result = [];

	if ( empty( $directory ) || ! is_string( $directory ) ) {
		return $result;
	}

	if ( file_exists( $directory ) && $handle = opendir( $directory ) ) {
		while ( false !== ( $file = readdir( $handle ) ) ) {
			if ( ! in_array( $file, ['..', '.'] ) ) {
				if ( is_dir( $directory . '/' . $file ) ) {
					$result   = array_merge( $result, papi_get_all_files_in_directory( $directory . '/' . $file ) );
				} else {
					$file     = $directory . '/' . $file;
					$result[] = preg_replace( '/\/\//si', '/', $file );
				}
			}
		}

		closedir( $handle );
	}

	return $result;
}

/**
 * Get core type file path, this allows classes to be overridden.
 *
 * @param  string $file_path
 *
 * @return string
 */
function papi_get_core_type_file_path( $file_path ) {
	if ( empty( $file_path ) ) {
		return [];
	}

	$directories = papi_filter_settings_directories();
	$result      = [];
{'fraction_non_alphanumeric': 0.18383371824480368, 'fraction_numerical': 0.0, 'mean_word_length': 2.82010582010582, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '615769', 'n_tokens_mistral': 847, 'n_tokens_neox': 775, 'n_words': 172}