getTemplateClassName() public method

Esempio n. 1
0
 private function generateModel()
 {
     $tableName = $this->input->getArgument('table');
     $className = $this->input->getOption('class');
     $fileName = $this->input->getOption('file');
     $nameSpace = $this->input->getOption('namespace');
     $tablePrefixToRemove = $this->input->getOption('remove-prefix') ?: 't';
     $shortArrays = $this->input->getOption('short-arrays');
     if (empty($tableName)) {
         $this->fail("Specify table name e.g. users");
     }
     try {
         $modelGenerator = new Generator($tableName, $className, $nameSpace, $tablePrefixToRemove, $shortArrays);
         $this->output->writeln('---------------------------------');
         $this->writeInfo('Database name: <info>%s</info>', Config::getValue('db', 'dbname'));
         $this->writeInfo('Class name: <info>%s</info>', $modelGenerator->getTemplateClassName());
         $this->writeInfo('Class namespace: <info>%s</info>', $modelGenerator->getClassNamespace());
         $this->output->writeln('---------------------------------');
         $this->output->writeln($modelGenerator->templateContents());
         $this->output->writeln('---------------------------------');
         if ($fileName) {
             $this->saveClassToFile($modelGenerator, $fileName);
         } else {
             $classFileName = ClassPathResolver::forClassAndNamespace($modelGenerator->getTemplateClassName(), $modelGenerator->getClassNamespace())->getClassFileName();
             $this->saveClassToFile($modelGenerator, $classFileName);
         }
     } catch (GeneratorException $e) {
         $this->fail($e->getMessage());
     }
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function shouldSingularizeTableName()
 {
     //given
     $generator = new Generator('order_products');
     //when
     $modelName = $generator->getTemplateClassName();
     //then
     $this->assertEquals('OrderProduct', $modelName);
 }