예제 #1
0
 /**
  * @param string|ClassBuilderProperty $property
  * @return ClassBuilderProperty
  */
 public function addProperty($property, Type $type = NULL)
 {
     $connect = FALSE;
     if (!$property instanceof ClassBuilderProperty) {
         $property = new ClassBuilderProperty($property, $this);
         if (isset($type)) {
             $property->setType($type);
         }
     } else {
         $connect = TRUE;
     }
     if (array_key_exists($key = mb_strtolower($property->getName()), $this->properties)) {
         throw new ClassBuilderException('Property ' . $property->getName() . ' existiert bereits');
     }
     $this->properties[$key] = $property;
     if ($connect) {
         $this->class->addProperty($property->getGProperty());
     }
     return $property;
 }