structure as $folder) { $path = rtrim($basePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $folder; if (!is_dir($path)) { mkdir($path, 0755, true); echo "Created directory: $path\n"; } else { echo "Directory already exists: $path\n"; } } foreach ($this->files as $file) { $filePath = rtrim($basePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file; if (!file_exists($filePath)) { file_put_contents($filePath, $this->getDefaultContent($file)); echo "Created file with default content: $filePath\n"; } else { $currentContent = file_get_contents($filePath); $defaultContent = $this->getDefaultContent($file); if (trim($currentContent) === '') { file_put_contents($filePath, $defaultContent); echo "Updated empty file with default content: $filePath\n"; } elseif (trim($currentContent) === trim($defaultContent)) { echo "File already has default content, no changes made: $filePath\n"; } else { echo "File has additional content, no changes made: $filePath\n"; } } } } private function getDefaultContent(string $file): string { if (preg_match('/app\/(Controllers|Core|Models|Services|Utils|Interfaces)\//', $file)) { $namespace = preg_replace('/app\/(.*?)\//', 'WizdomNetworks\\WizeWeb\\$1', dirname($file)); $namespace = str_replace('/', '\\', $namespace); $className = pathinfo($file, PATHINFO_FILENAME); return "\n"; exit(1); } $path = $argv[1]; $generator = new StructureGenerator(); $generator->createStructure($path); } ?>