/** * Returns the array of lines to declare the setter * @uses WsdlToPhpModel::getModelByName() * @uses WsdlToPhpModel::getCleanName() * @uses WsdlToPhpModel::nameIsClean() * @uses WsdlToPhpModel::getName() * @uses WsdlToPhpModel::getPackagedName() * @uses WsdlToPhpModel::getInheritance() * @uses WsdlToPhpStruct::getIsRestriction() * @uses WsdlToPhpStruct::isArray() * @uses WsdlToPhpStructAttribute::getType() * @uses WsdlToPhpStructAttribute::getSetterName() * @uses WsdlToPhpStructAttribute::getOwner() * @param array $_body * @param WsdlToPhpStruct $_struct * @return void */ public function getSetterDeclaration(&$_body, WsdlToPhpStruct $_struct) { $model = self::getModelByName($this->getType()); /** * set() method comment */ $comments = array(); array_push($comments, 'Set ' . $this->getName() . ' value'); if ($model && $model->getIsRestriction() && !$_struct->isArray()) { array_push($comments, '@uses ' . $model->getPackagedName() . '::valueIsValid()'); } if ($model) { if ($model->getIsStruct() && $model->getPackagedName() != $this->getOwner()->getPackagedName()) { array_push($comments, '@param ' . $model->getPackagedName() . ' $_' . lcfirst($this->getCleanName()) . ' the ' . $this->getName()); array_push($comments, '@return ' . $model->getPackagedName()); } else { array_push($comments, '@param ' . ($model->getInheritance() ? $model->getInheritance() : $this->getType()) . ' $_' . lcfirst($this->getCleanName()) . ' the ' . $this->getName()); array_push($comments, '@return ' . ($model->getInheritance() ? $model->getInheritance() : $this->getType())); } } else { array_push($comments, '@param ' . $this->getType() . ' $_' . lcfirst($this->getCleanName()) . ' the ' . $this->getName()); array_push($comments, '@return ' . $this->getType()); } array_push($_body, array('comment' => $comments)); /** * set() method body */ array_push($_body, 'public function ' . $this->getSetterName() . '($_' . lcfirst($this->getCleanName()) . ')'); array_push($_body, '{'); if ($model && $model->getIsRestriction() && !$_struct->isArray()) { array_push($_body, 'if(!' . $model->getPackagedName() . '::valueIsValid($_' . lcfirst($this->getCleanName()) . '))'); array_push($_body, '{'); array_push($_body, 'return false;'); array_push($_body, '}'); } if ($this->nameIsClean()) { array_push($_body, 'return ($this->' . $this->getName() . ' = $_' . lcfirst($this->getCleanName()) . ');'); } else { array_push($_body, 'return ($this->' . $this->getCleanName() . ' = $this->{\'' . addslashes($this->getName()) . '\'} = $_' . lcfirst($this->getCleanName()) . ');'); } array_push($_body, '}'); unset($model, $comments); }