/**
  * Adds a new Property on the collection.
  *
  * @param PropertyInterface $property
  *
  * @return bool
  * @throws \InvalidArgumentException
  */
 public function add($property)
 {
     if (!$property instanceof PropertyInterface) {
         throw new \InvalidArgumentException('This Property must be a instance of \\ClassGeneration\\PropertyInterface');
     }
     if ($property->getName() === null) {
         $property->setName('property' . ($this->count() + 1));
     }
     parent::set($property->getName(), $property);
     return true;
 }
 /**
  * Creates Argument from Property Object.
  *
  * @param PropertyInterface $property
  *
  * @return Argument
  */
 public static function createFromProperty(PropertyInterface $property)
 {
     $argument = new self();
     $argument->setName($property->getName())->setType($property->getType());
     return $argument;
 }
Example #3
0
 /**
  * Create var tag from property.
  *
  * @param PropertyInterface $property
  *
  * @return Tag
  */
 public static function createFromProperty(PropertyInterface $property)
 {
     $tag = new self();
     $tag->setName(self::TAG_VAR);
     $tag->setType($property->getType());
     return $tag;
 }
 /**
  * @inheritdoc
  */
 public function addProperty(PropertyInterface $property)
 {
     $property->setParent($this);
     $this->getPropertyCollection()->add($property);
     return $this;
 }
 /**
  * Create a Get Method from Property of Class.
  *
  * @param PropertyInterface $property
  *
  * @return Method
  */
 public static function createGetterFromProperty(PropertyInterface $property)
 {
     $method = new self();
     $method->setName('get_' . $property->getName());
     $method->setCode('return $this->' . $property->getName() . ';');
     return $method;
 }