/** * 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; }
/** * 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; }