示例#1
0
 /**
  * @param string $name
  * @return string
  */
 protected function normalize($name)
 {
     // Strip m:n delimiters
     $name = Helpers::stripMnDelimiters($name, '_');
     // Convert to camelCase
     $name = Helpers::camelCase($name);
     return $name;
 }
示例#2
0
 /**
  * @param PhpNamespace $namespace
  * @param ClassType $class
  * @param Column $column
  * @return void
  */
 public function doDecorate(Column $column, ClassType $class, PhpNamespace $namespace)
 {
     $column->setPhpDoc($doc = new PhpDoc());
     // Annotation
     $doc->setAnnotation('@property');
     // Type
     if ($column->isNullable()) {
         $doc->setType($this->getRealType($column) . '|NULL');
     } else {
         $doc->setType($this->getRealType($column));
     }
     // Variable
     $doc->setVariable(Helpers::camelCase($column->getName()));
     // Defaults
     if ($column->getDefault() !== NULL) {
         $doc->setDefault($this->getRealDefault($column));
     }
     // Enum
     if (!empty($enum = $column->getEnum())) {
         $doc->setEnum(Strings::upper($column->getName()));
     }
     // Relations
     if (($key = $column->getForeignKey()) !== NULL) {
         // Find foreign entity table
         $ftable = $column->getTable()->getDatabase()->getForeignTable($key->getReferenceTable());
         // Update type to Entity name
         $doc->setType($this->resolver->resolveEntityName($ftable));
         $doc->setRelation($relDoc = new PhpRelDoc());
         if ($use = $this->getRealUse($ftable, $namespace)) {
             $namespace->addUse($use);
         }
         $relDoc->setType('???');
         $relDoc->setEntity($this->resolver->resolveEntityName($ftable));
         $relDoc->setVariable('???');
     }
     // Append phpDoc to class
     $class->addDocument((string) $column->getPhpDoc());
 }