/** * Render for class * * @param Maker $maker * @param $body * @return string */ public function maker_class(Maker $maker, $body) { $content = ''; $reflection = $maker->getClass(); // NAMESPACE if ($maker->hasNamespace()) { $content .= 'namespace ' . $maker->getNamespace() . ';' . PHP_EOL; } $content .= str_repeat(PHP_EOL, 2); // ALIASES if ($maker->hasAliases()) { foreach ($aliases = $maker->getAliases() as $alias => $class) { $content .= 'use ' . $class; if (collect(explode('\\', $class))->last() != $alias) { $content .= ' as ' . $alias; } $content .= ';' . PHP_EOL; } $content .= str_repeat(PHP_EOL, 2); } // DOCBLOCK $content .= $this->render('docblock', $maker); // declaration $content .= 'class ' . $reflection->getShortName(); // PARENT if ($parent = $maker->getParent()) { $content .= ' extends ' . $maker->findAliasName($parent); } // @todo Gestion des interfaces // $interface = $reflection->getImmediateInterfaces(); $content .= PHP_EOL; $content .= '{' . PHP_EOL . "\t" . str_replace(PHP_EOL, PHP_EOL . "\t", trim($body)) . PHP_EOL . '}'; return $content; }