Exemple #1
0
 private function addUnserializeFunction()
 {
     $element = new ClassMethodElement('unserialize', 'public');
     $element->setDescription('(non-PHPdoc)');
     $element->addAnnotation('see', 'Serializable::serialize()');
     $element->addVariable('data', 'string');
     $element->addBodyLine('$object = unserialize($data);');
     $element->addBodyLine('foreach ($object as $variable => $value) {');
     $element->addBodyLine('    $this->$variable = $value;');
     $element->addBodyLine('}');
     $this->classFile->addElement($element);
 }
Exemple #2
0
 public function __construct($propertyName, $type)
 {
     $functionName = 'get' . ucfirst($propertyName);
     parent::__construct($functionName, 'public');
     $this->returns('string');
     $this->addBodyLine('return $this->' . $propertyName . ';');
 }
 public function __construct($variables)
 {
     parent::__construct('__construct', 'public');
     foreach ($variables as $name => $type) {
         $this->addVariable($name, $type);
         $this->addBodyLine('$this->' . $name . ' = $' . $name . ';');
     }
 }
Exemple #4
0
 private function createPopulated()
 {
     $element = new ClassMethodElement('createPopulated' . $this->className, 'public');
     $element->returns($this->classNameSpace . '\\' . $this->className);
     $params = array();
     foreach ($this->constantNames as $name) {
         $params[] = 'self::VALID_' . $name['constant'];
     }
     $element->addBodyLine('return new ' . $this->className . '(' . implode(', ', $params) . ');');
     $this->addElement($element);
 }