/** * Returns the name of the value as constant * @see WsdlToPhpModel::getCleanName() * @uses WsdlToPhpModel::getCleanName() * @uses WsdlToPhpModel::getName() * @uses WsdlToPhpModel::getOwner() * @uses WsdlToPhpStructValue::constantSuffix() * @uses WsdlToPhpStructValue::getIndex() * @uses WsdlToPhpStructValue::getOwner() * @uses WsdlToPhpGenerator::getOptionGenericConstantsNames() * @param bool $_keepMultipleUnderscores optional, allows to keep the multiple consecutive underscores * @return string */ public function getCleanName($_keepMultipleUnderscores = false) { if (WsdlToPhpGenerator::getOptionGenericConstantsNames() && is_numeric($this->getIndex()) && $this->getIndex() >= 0) { return 'ENUM_VALUE_' . $this->getIndex(); } else { $key = self::constantSuffix($this->getOwner()->getName(), parent::getCleanName($_keepMultipleUnderscores), $this->getIndex()); return 'VALUE_' . strtoupper(parent::getCleanName($_keepMultipleUnderscores)) . ($key ? '_' . $key : ''); } }
/** * Gets category part * @uses WsdlToPhpGenerator::getOptionCategory() * @uses WsdlToPhpGenerator::getOptionSubCategory() * @uses WsdlToPhpGenerator::getPart() * @uses WsdlToPhpGenerator::getOptionGatherMethods() * @uses WsdlToPhpModel::getCleanName() * @uses WsdlToPhpModel::getContextualPart() * @param WsdlToPhpModel $_model the model for which we generate the folder * @param string $_optionName category type * @return string */ protected function getPart(WsdlToPhpModel $_model, $_optionName) { $elementType = ''; $optionValue = 0; $string = $_model->getCleanName(); switch ($_optionName) { case self::OPT_CAT_KEY: $optionValue = self::getOptionCategory(); break; case self::OPT_SUB_CAT_KEY: $optionValue = self::getOptionSubCategory(); $mainCatPart = $this->getPart($_model, self::OPT_CAT_KEY); switch (self::getOptionCategory()) { case self::OPT_CAT_END_NAME: if ($string != $mainCatPart && strlen($mainCatPart) < strlen($string)) { $string = substr($string, 0, strlen($string) - strlen($mainCatPart)); } elseif ($string == $mainCatPart) { $string = ''; } break; case self::OPT_CAT_START_NAME: if ($string != $mainCatPart && strlen($mainCatPart) < strlen($string)) { $string = substr($string, strlen($mainCatPart)); } elseif ($string == $mainCatPart) { $string = ''; } break; case self::OPT_CAT_NONE_NAME: case self::OPT_CAT_TYPE: default: $string = ''; break; } break; case self::OPT_GATH_METH_KEY: $optionValue = self::getOptionGatherMethods(); break; } if (!empty($string)) { switch ($optionValue) { case self::OPT_CAT_END_NAME: case self::OPT_SUB_CAT_END_NAME: case self::OPT_GATH_METH_END_NAME: /** * Determine category from last word */ $parts = preg_split('/[A-Z]/', ucfirst($string)); /** * Ex : Error or error */ if (count($parts) == 0) { $elementType = $string; } elseif (!empty($parts[count($parts) - 1])) { $elementType = substr($string, strrpos($string, implode('', array_slice($parts, -1))) - 1); } else { $part = ''; for ($i = count($parts) - 1; $i >= 0; $i--) { $part = trim($parts[$i]); if (!empty($part)) { break; } } $elementType = substr($string, (count($parts) - 2 - $i + 1) * -1); } break; case self::OPT_CAT_START_NAME: case self::OPT_SUB_CAT_START_NAME: case self::OPT_GATH_METH_START_NAME: /** * Determine category from first word */ $parts = preg_split('/[A-Z]/', ucfirst($string)); /** * Ex : Error or error */ if (count($parts) == 0) { $elementType = $string; } elseif (empty($parts[0]) && !empty($parts[1])) { $elementType = substr($string, 0, strlen($parts[1]) + 1); } else { $part = ''; for ($i = 0; $i < count($parts); $i++) { $part = trim($parts[$i]); if (!empty($part)) { break; } } $elementType = substr($string, 0, $i); } break; case self::OPT_CAT_TYPE: $elementType = $_model->getContextualPart(); break; case self::OPT_CAT_NONE_NAME: case self::OPT_SUB_CAT_NONE_NAME: default: break; } } return $elementType; }