<commit_before><?php

use Silex\Provider\TwigServiceProvider;

// Iterate through all modules and all all routes from any php files inside the controller directories
// Each controller file must return an instance of $app
$path = __DIR__ . '/modules/';
$dirIterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
$fileIterator = new IteratorIterator($dirIterator);
$viewDirs = [];

foreach ($fileIterator as $modulePath => $module) {
	foreach(new RecursiveDirectoryIterator($module, FilesystemIterator::SKIP_DOTS) as $dirName => $directory) {
		$dirNameSplit = explode(DIRECTORY_SEPARATOR, $dirName);

		// Require controller files (must return $app back)
		if ($dirNameSplit[count($dirNameSplit) - 1] == 'controllers') {
			foreach(new RecursiveDirectoryIterator($dirName, FilesystemIterator::SKIP_DOTS) as $controllerName => $controller) {
				$app = require_once($controllerName);
			}
		}
		else if ($dirNameSplit[count($dirNameSplit) - 1] == 'views') {
			// Get a list of views directories to pass to twig or hopfeully Zend_View soon
			$viewDirs[] = $dirName;
		}
	}<commit_msg>Refactoring<commit_after><?php

use Silex\Provider\TwigServiceProvider;

// Iterate through all modules and all all routes from any php files inside the controller directories
// Each controller file must return an instance of $app
$path = __DIR__ . '/modules/';
$dirIterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
$fileIterator = new IteratorIterator($dirIterator);
$viewDirs = [];

foreach ($fileIterator as $modulePath => $module) {
	foreach(new RecursiveDirectoryIterator($module, FilesystemIterator::SKIP_DOTS) as $dirName => $directory) {
		$dirNameSplit = explode(DIRECTORY_SEPARATOR, $dirName);

		// Require controller files (must return $app back)
		if ('controllers' == $dirNameSplit[count($dirNameSplit) - 1]) {
			foreach(new RecursiveDirectoryIterator($dirName, FilesystemIterator::SKIP_DOTS) as $controllerName => $controller) {
				$app = require_once($controllerName);
			}
		}
		else if ('views' == $dirNameSplit[count($dirNameSplit) - 1]) {
			// Get a list of views directories to pass to twig or hopfeully Zend_View soon
			$viewDirs[] = $dirName;
		}
	}
{'fraction_non_alphanumeric': 0.11992786293958521, 'fraction_numerical': 0.0018034265103697023, 'mean_word_length': 5.507331378299121, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '568974', 'n_tokens_mistral': 709, 'n_tokens_neox': 665, 'n_words': 186}