<commit_before><?php

	namespace Hippo;

	use Hippo\Exception\FileNotFoundException;
	use Hippo\Exception\FileNotWritableException;
	use Hippo\Exception\FileNotReadableException;

	use \RecursiveDirectoryIterator;
	use \RecursiveIteratorIterator;
	use \RegexIterator;

	class FileSystem {
		/**
		 * @param string $path
		 * @return string
		 */
		public function getContent($path) {
			if (!file_exists($path)) {
				throw new FileNotFoundException($path);
			}
			if (is_dir($path) || !is_readable($path)) {
				throw new FileNotReadableException($path);
			}
			return file_get_contents($path);
		}

		/**
		 * @param string $path
		 * @param string $content
		 * @return void
		 */
		public function putContent($path, $content) {
			if (file_exists($path) and is_dir($path)) {
				throw new FileNotWritableException($path);
			}
			if (!is_writable(dirname($path))) {
				throw new FileNotWritableException($path);
			}
			file_put_contents($path, $content);
		}

		/**
		 * @param string $path
		 * @param string $regex
		 * @return string[]
		 */
		public function getAllFiles($initialDirectory, $regex = null) {
			$directoryIterator = new RecursiveDirectoryIterator($initialDirectory, RecursiveDirectoryIterator::SKIP_DOTS);
			$flattenedIterator = new RecursiveIteratorIterator($directoryIterator);
			$iterator = $regex !== null
				? new RegexIterator($flattenedIterator, $regex)
				: $flattenedIterator;

			$output = [];
			foreach ($iterator as $i) {
				$output[] = $i->getRealpath();
			}
			return $output;
		}
	}<commit_msg>Added more determinism to the FileSystem<commit_after><?php

	namespace Hippo;

	use Hippo\Exception\FileNotFoundException;
	use Hippo\Exception\FileNotWritableException;
	use Hippo\Exception\FileNotReadableException;

	use \RecursiveDirectoryIterator;
	use \RecursiveIteratorIterator;
	use \RegexIterator;

	class FileSystem {
		/**
		 * @param string $path
		 * @return string
		 */
		public function getContent($path) {
			if (!file_exists($path)) {
				throw new FileNotFoundException($path);
			}
			if (is_dir($path) || !is_readable($path)) {
				throw new FileNotReadableException($path);
			}
			return file_get_contents($path);
		}

		/**
		 * @param string $path
		 * @param string $content
		 * @return void
		 */
		public function putContent($path, $content) {
			if (file_exists($path) and is_dir($path)) {
				throw new FileNotWritableException($path);
			}
			if (!is_writable(dirname($path))) {
				throw new FileNotWritableException($path);
			}
			file_put_contents($path, $content);
		}

		/**
		 * @param string $path
		 * @param string $regex
		 * @return string[]
		 */
		public function getAllFiles($initialDirectory, $regex = null) {
			$directoryIterator = new RecursiveDirectoryIterator($initialDirectory, RecursiveDirectoryIterator::SKIP_DOTS);
			$flattenedIterator = new RecursiveIteratorIterator($directoryIterator);
			$iterator = $regex !== null
				? new RegexIterator($flattenedIterator, $regex)
				: $flattenedIterator;

			$output = [];
			foreach ($iterator as $i) {
				$output[] = $i->getRealpath();
			}
			usort($output, function($a, $b) {
				return strnatcasecmp($a, $b);
			});
			return $output;
		}
	}
{'fraction_non_alphanumeric': 0.13162018176120338, 'fraction_numerical': 0.0, 'mean_word_length': 4.050632911392405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1648425', 'n_tokens_mistral': 1178, 'n_tokens_neox': 977, 'n_words': 211}