public function generate(FileGenerator $file, $type)
{
$class = $file->getClass() ?: new ClassGenerator();
$class->setNamespaceName($type->getNamespace());
$class->setName($type->getName());
$this->ruleSet->applyRules(new TypeContext($class, $type));
foreach ($type->getProperties() as $property) {
$this->ruleSet->applyRules(new PropertyContext($class, $type, $property));
}
$file->setClass($class);
return $file->generate();
}
/** * Generates one type class * * @param FileGenerator $file * @param TypeGenerator $generator * @param Type $type * @param string $path */ protected function generateType(FileGenerator $file, TypeGenerator $generator, Type $type, $path) { $code = $generator->generate($file, $type); $this->filesystem->putFileContents($path, $code); }