public function generate($path)
{
if ($this->config->get('indent', 'extra') === 'tabs') {
$indent = "\t";
} else {
$indent = ' ';
}
$namespace = $this->config->get('namespace');
foreach ($this->files as $file) {
$class = $file->getClassDefinition();
$source = $this->buildClass($class, $indent);
$filename = ucfirst($class->getName()) . '.zep.php';
$filePath = $path . str_replace($namespace, '', str_replace($namespace . '\\\\', DIRECTORY_SEPARATOR, strtolower($class->getNamespace())));
$filePath = str_replace('\\', DIRECTORY_SEPARATOR, $filePath);
$filePath = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $filePath);
if (!is_dir($filePath)) {
mkdir($filePath, 0777, true);
}
$filePath = realpath($filePath) . '/';
file_put_contents($filePath . $filename, $source);
}
}