public function getTypeName(Type $type) { $name = $this->classify($type->getName()); if ($name && substr($name, -4) !== 'Type') { $name .= "Type"; } return $name; }
public function getTypeName(Type $type) { return $this->classify($type->getName()) . "Type"; }
private function findPHPName(Type $type) { $schema = $type->getSchema(); if ($className = $this->getTypeAlias($type)) { if (($pos = strrpos($className, '\\')) !== false) { return [substr($className, $pos + 1), substr($className, 0, $pos)]; } else { return [$className, null]; } } $name = $this->getNamingStrategy()->getTypeName($type); if (!isset($this->namespaces[$schema->getTargetNamespace()])) { throw new Exception(sprintf("Can't find a PHP namespace to '%s' namespace", $schema->getTargetNamespace())); } $ns = $this->namespaces[$schema->getTargetNamespace()]; return [$name, $ns]; }
public function addType(Type $type) { $this->types[$type->getName()] = $type; }
private function loadRestriction(Type $type, DOMElement $node) { $restriction = new Restriction(); $type->setRestriction($restriction); if ($node->hasAttribute("base")) { $restrictedType = $this->findSomething('findType', $type->getSchema(), $node, $node->getAttribute("base")); $restriction->setBase($restrictedType); } else { $addCallback = function ($restType) use($restriction) { $restriction->setBase($restType); }; foreach ($node->childNodes as $childNode) { switch ($childNode->localName) { case 'simpleType': call_user_func($this->loadSimpleType($type->getSchema(), $childNode, $addCallback)); break; } } } foreach ($node->childNodes as $childNode) { if (in_array($childNode->localName, ['enumeration', 'pattern', 'length', 'minLength', 'maxLength', 'minInclusive', 'maxInclusive', 'minExclusive', 'maxExclusive', 'fractionDigits', 'totalDigits', 'whiteSpace'], true)) { $restriction->addCheck($childNode->localName, ['value' => $childNode->getAttribute("value"), 'doc' => $this->getDocumentation($childNode)]); } } }
/** * @param Type $type * @return \GoetasWebservices\XML\XSDReader\Schema\Element\ElementSingle|null */ protected function isArrayNestedElement(Type $type) { if ($type instanceof ComplexType && !$type->getParent() && !$type->getAttributes() && count($type->getElements()) === 1) { $elements = $type->getElements(); return $this->isArrayElement(reset($elements)); } }
private function findPHPName(Type $type) { $schema = $type->getSchema(); if ($alias = $this->getTypeAlias($type, $schema)) { return $alias; } $ns = $this->findPHPNamespace($type); $name = $this->getNamingStrategy()->getTypeName($type); return $ns . "\\" . $name; }
public function &visitType(Type $type, $force = false) { $skip = in_array($type->getSchema()->getTargetNamespace(), $this->baseSchemas, true); if (!isset($this->classes[spl_object_hash($type)])) { $this->classes[spl_object_hash($type)]["skip"] = $skip; if ($alias = $this->getTypeAlias($type)) { $class = array(); $class[$alias] = array(); $this->classes[spl_object_hash($type)]["class"] =& $class; $this->classes[spl_object_hash($type)]["skip"] = true; return $class; } $className = $this->findPHPName($type); $class = array(); $data = array(); $class[$className] =& $data; $this->classes[spl_object_hash($type)]["class"] =& $class; $this->visitTypeBase($class, $data, $type, $type->getName()); if ($type instanceof SimpleType) { $this->classes[spl_object_hash($type)]["skip"] = true; return $class; } if (!$force && ($this->isArrayType($type) || $this->isArrayNestedElement($type))) { $this->classes[spl_object_hash($type)]["skip"] = true; return $class; } } elseif ($force) { if (!$type instanceof SimpleType && !$this->getTypeAlias($type)) { $this->classes[spl_object_hash($type)]["skip"] = $skip; } } return $this->classes[spl_object_hash($type)]["class"]; }