dirList as $dir) { $this->processForDir($dir); } } public function getCount(): int { return $this->counter; } private function processForDir(string $dir): void { $directory = new RecursiveDirectoryIterator($dir); $fullTree = new RecursiveIteratorIterator($directory); $phpFiles = new RegexIterator($fullTree, '/.+((? $file) { $this->processFile($file[0]); } } private function processFile(string $file): void { if ($this->isFileToBeIgnored($file)) { return; } require_once($file); $this->counter++; } private function isFileToBeIgnored(string $file): bool { $file = str_replace('\\', '/', $file); foreach ($this->ignoreList as $item) { if (str_starts_with($file, $item)) { return true; } } if (str_contains($file, 'vendor/composer/ClassLoader.php')) { return true; } return false; } }