public function testGetGeneratedNamespaceName() { $class = 'Hostnet\\Component\\EntityPlugin\\Foo'; $package_class = new PackageClass($class, new \SplFileInfo(__FILE__)); $this->assertEquals('Hostnet\\Component\\EntityPlugin\\Generated', $package_class->getGeneratedNamespaceName()); }
/** * Generates Generated/<class_name>Traits.php * * @param PackageClass $package_class * @param array $traits */ private function generateTrait(PackageClass $package_class, array $traits) { $short_name = $package_class->getShortName(); $this->writeIfVeryVerbose(' - Generating trait of traits for <info>' . $package_class->getName() . '</info>'); $generated_namespace = $package_class->getGeneratedNamespaceName(); $use_statements = array_filter($traits, function (PackageClass $stmt) { return $stmt->isTrait(); }); sort($use_statements); $data = $this->environment->render('trait.php.twig', ['class_name' => $short_name, 'namespace' => $generated_namespace, 'use_statements' => $use_statements]); $this->filesystem->dumpFile($package_class->getGeneratedDirectory() . $short_name . 'Trait.php', $data); }