Esempio n. 1
0
 /**
  * Generate Set Method from Property.
  * Add a set method in the class based on Object Property.
  *
  * @param PropertyInterface $property
  *
  * @return Method
  */
 public static function createSetterFromProperty(PropertyInterface $property)
 {
     $argument = Argument::createFromProperty($property);
     $code = "\$this->{$property->getName()} = {$argument->getNameFormatted()};" . PHP_EOL . 'return $this;';
     $method = new self();
     $method->setName('set_' . $property->getName())->setCode($code)->getArgumentCollection()->add($argument);
     return $method;
 }