Esempio n. 1
0
 /**
  *
  * @param PHPProperty $property
  * @return $this
  */
 public function addProperty(PHPProperty $property)
 {
     $this->properties[$property->getName()] = $property;
     return $this;
 }
Esempio n. 2
0
 /**
  * setProperty()
  *
  * @param array|\Zend\CodeGenerator\PHP\PHPProperty $property
  * @return \Zend\CodeGenerator\PHP\PHPClass
  */
 public function setProperty($property)
 {
     if (is_array($property)) {
         $property = new PHPProperty($property);
         $propertyName = $property->getName();
     } elseif ($property instanceof PHPProperty) {
         $propertyName = $property->getName();
     } else {
         throw new Exception('setProperty() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property');
     }
     if (isset($this->_properties[$propertyName])) {
         throw new Exception('A property by name ' . $propertyName . ' already exists in this class.');
     }
     $this->_properties[$propertyName] = $property;
     return $this;
 }