/**
* @interitdoc
*/
public function __invoke($name, $namespace, $classToExtend, $fileDocBlock = null)
{
$interfaces = $this->getImplementedInterfaces();
$properties = $this->getClassProperties();
$flags = $this->getClassFlags();
$methods = $this->getMethods($name);
$traits = $this->getTraits();
// getUses() must called at the end to allow other methods to add import namespaces directives
$uses = $this->getUses();
$fileDocBlock = new DocBlockGenerator($fileDocBlock);
if ($classToExtend) {
$uses[] = ltrim($classToExtend, '\\');
$classToExtend = substr($classToExtend, strrpos($classToExtend, '\\') + 1);
}
switch (get_class($this)) {
case 'Prooph\\Cli\\Code\\Generator\\CommandHandler':
$className = $name . 'Handler';
break;
case 'Prooph\\Cli\\Code\\Generator\\CommandHandlerFactory':
$className = $name . 'HandlerFactory';
break;
default:
$className = $name;
break;
}
$class = new ClassGenerator($className, $namespace, $flags, $classToExtend, $interfaces, $properties, $methods, $this->getClassDocBlock($name));
foreach ($traits as $trait) {
$class->addTrait($trait);
}
return new FileGenerator(['classes' => [$class], 'namespace' => $namespace, 'uses' => $uses, 'docBlock' => $fileDocBlock]);
}