Ouzo\Tools\Model\Template\Generator::getClassNamespace PHP Method

getClassNamespace() public method

public getClassNamespace ( )
    public function getClassNamespace()
    {
        $parts = explode('\\', $this->namespace);
        $parts = Arrays::map($parts, 'ucfirst');
        $modelNamespace = trim(AutoloadNamespaces::getModelNamespace(), '\\');
        if (!Strings::startsWith($this->namespace, $modelNamespace)) {
            $parts = array_merge(array($modelNamespace), $parts);
        }
        $parts = Arrays::filterNotBlank($parts);
        return implode('\\', $parts);
    }

Usage Example

Example #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());
     }
 }
All Usage Examples Of Ouzo\Tools\Model\Template\Generator::getClassNamespace