1 | <?php |
||
5 | abstract class AbstractElementHandler extends AbstractNodeHandler |
||
6 | { |
||
7 | /** |
||
8 | * @param \DOMElement $element |
||
9 | * @param AbstractDomDocumentHandler $domDocument |
||
10 | * @param int $index |
||
11 | */ |
||
12 | 672 | public function __construct(\DOMElement $element, AbstractDomDocumentHandler $domDocument, $index = -1) |
|
13 | { |
||
14 | 672 | parent::__construct($element, $domDocument, $index); |
|
15 | 672 | } |
|
16 | /** |
||
17 | * @see \WsdlToPhp\PackageGenerator\DomHandler\AbstractNodeHandler::getNode() |
||
18 | * @return \DOMElement |
||
19 | */ |
||
20 | 628 | public function getNode() |
|
21 | { |
||
22 | 628 | return parent::getNode(); |
|
23 | } |
||
24 | /** |
||
25 | * Alias to getNode() |
||
26 | * @return \DOMElement |
||
27 | */ |
||
28 | 592 | public function getElement() |
|
29 | { |
||
30 | 592 | return $this->getNode(); |
|
31 | } |
||
32 | /** |
||
33 | * @param string $name |
||
34 | * @return boolean |
||
35 | */ |
||
36 | 584 | public function hasAttribute($name) |
|
37 | { |
||
38 | 584 | return $this->getElement()->hasAttribute($name); |
|
39 | } |
||
40 | /** |
||
41 | * @param string $name |
||
42 | * @return AttributeHandler|null |
||
43 | */ |
||
44 | 580 | public function getAttribute($name) |
|
45 | { |
||
46 | 580 | return $this->hasAttribute($name) ? $this->getDomDocumentHandler()->getHandler($this->getNode()->getAttributeNode($name)) : null; |
|
47 | } |
||
48 | /** |
||
49 | * @param string $name |
||
50 | * @return mixed |
||
51 | */ |
||
52 | 352 | public function getAttributeValue($name, $withNamespace = false, $withinItsType = true, $asType = AbstractAttributeHandler::DEFAULT_VALUE_TYPE) |
|
61 | /** |
||
62 | * @param string $name |
||
63 | * @return NodeHandler[]|ElementHandler[] |
||
64 | */ |
||
65 | 296 | public function getChildrenByName($name) |
|
66 | { |
||
67 | 296 | $children = array(); |
|
68 | 296 | if ($this->hasChildren()) { |
|
69 | 296 | foreach ($this->getElement()->getElementsByTagName($name) as $index=>$node) { |
|
70 | 288 | $children[] = $this->getDomDocumentHandler()->getHandler($node, $index); |
|
71 | 222 | } |
|
72 | 222 | } |
|
73 | 296 | return $children; |
|
74 | } |
||
75 | /** |
||
76 | * @return ElementHandler[] |
||
77 | */ |
||
78 | 116 | public function getElementChildren() |
|
79 | { |
||
80 | 116 | $children = array(); |
|
81 | 116 | if ($this->hasChildren()) { |
|
82 | 92 | $children = $this->getDomDocumentHandler()->getElementsHandlers($this->getChildNodes()); |
|
83 | 69 | } |
|
84 | 116 | return $children; |
|
85 | } |
||
86 | /** |
||
87 | * @param string $name |
||
88 | * @param array $attributes |
||
89 | * @return ElementHandler[] |
||
90 | */ |
||
91 | 80 | public function getChildrenByNameAndAttributes($name, array $attributes) |
|
92 | { |
||
93 | 80 | return $this->getDomDocumentHandler()->getElementsByNameAndAttributes($name, $attributes, $this->getNode()); |
|
94 | } |
||
95 | /** |
||
96 | * @param string $name |
||
97 | * @param array $attributes |
||
98 | * @return ElementHandler|null |
||
99 | */ |
||
100 | 80 | public function getChildByNameAndAttributes($name, array $attributes) |
|
101 | { |
||
102 | 80 | $children = $this->getChildrenByNameAndAttributes($name, $attributes); |
|
103 | 80 | return empty($children) ? null : array_shift($children); |
|
104 | } |
||
105 | /** |
||
106 | * Info at {@link https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints} |
||
107 | * @return mixed |
||
108 | */ |
||
109 | 288 | public function getMaxOccurs() |
|
120 | /** |
||
121 | * Info at {@link https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints} |
||
122 | * @return int |
||
123 | */ |
||
124 | 308 | public function getMinOccurs() |
|
132 | /** |
||
133 | * Info at {@link http://www.w3schools.com/xml/el_element.asp} |
||
134 | * @return bool |
||
135 | */ |
||
136 | 256 | public function getNillable() |
|
137 | { |
||
138 | 256 | return (bool)$this->getAttributeValue(AbstractAttributeHandler::ATTRIBUTE_NILLABLE, false, true, 'bool'); |
|
139 | } |
||
140 | /** |
||
141 | * Info at {@link https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints} |
||
142 | * @return bool |
||
143 | */ |
||
144 | 272 | public function canOccurSeveralTimes() |
|
148 | /** |
||
149 | * Info at {@link https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints} |
||
150 | * @return bool |
||
151 | */ |
||
152 | 8 | public function canOccurOnlyOnce() |
|
156 | /** |
||
157 | * Info at {@link https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints} |
||
158 | * @return bool |
||
159 | */ |
||
160 | 288 | public function isOptional() |
|
164 | /** |
||
165 | * Info at {@link https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints} |
||
166 | * @return bool |
||
167 | */ |
||
168 | 8 | public function isRequired() |
|
172 | /** |
||
173 | * @return bool |
||
174 | */ |
||
175 | 284 | public function isRemovable() |
|
179 | } |
||
180 |