1
|
|
|
<?php |
2
|
|
|
namespace GoetasWebservices\XML\XSDReader\Schema\Element; |
3
|
|
|
|
4
|
|
|
use DOMElement; |
5
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Item; |
6
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Schema; |
7
|
|
|
use GoetasWebservices\XML\XSDReader\SchemaReader; |
8
|
|
|
|
9
|
|
|
class ElementRef extends Item implements ElementSingle |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var ElementDef |
13
|
|
|
*/ |
14
|
|
|
protected $wrapped; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var int |
18
|
|
|
*/ |
19
|
|
|
protected $min = 1; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var int |
23
|
|
|
*/ |
24
|
|
|
protected $max = 1; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var bool |
28
|
|
|
*/ |
29
|
|
|
protected $qualified = true; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var bool |
33
|
|
|
*/ |
34
|
|
|
protected $nil = false; |
35
|
|
|
|
36
|
135 |
|
public function __construct(ElementDef $element) |
37
|
|
|
{ |
38
|
135 |
|
parent::__construct($element->getSchema(), $element->getName()); |
39
|
135 |
|
$this->wrapped = $element; |
40
|
135 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
* @return ElementDef |
45
|
|
|
*/ |
46
|
|
|
public function getReferencedElement() |
47
|
|
|
{ |
48
|
|
|
return $this->wrapped; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return \GoetasWebservices\XML\XSDReader\Schema\Type\Type|null |
53
|
|
|
*/ |
54
|
|
|
public function getType() |
55
|
|
|
{ |
56
|
|
|
return $this->wrapped->getType(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return int |
61
|
|
|
*/ |
62
|
|
|
public function getMin() |
63
|
|
|
{ |
64
|
|
|
return $this->min; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param int $min |
69
|
|
|
* |
70
|
|
|
* @return $this |
71
|
|
|
*/ |
72
|
135 |
|
public function setMin($min) |
73
|
|
|
{ |
74
|
135 |
|
$this->min = $min; |
75
|
135 |
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return int |
80
|
|
|
*/ |
81
|
|
|
public function getMax() |
82
|
|
|
{ |
83
|
|
|
return $this->max; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param int $max |
88
|
|
|
* |
89
|
|
|
* @return $this |
90
|
|
|
*/ |
91
|
135 |
|
public function setMax($max) |
92
|
|
|
{ |
93
|
135 |
|
$this->max = $max; |
94
|
135 |
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
|
|
public function isQualified() |
101
|
|
|
{ |
102
|
|
|
return $this->qualified; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param bool $qualified |
107
|
|
|
* |
108
|
|
|
* @return $this |
109
|
|
|
*/ |
110
|
|
|
public function setQualified($qualified) |
111
|
|
|
{ |
112
|
|
|
$this->qualified = is_bool($qualified) ? $qualified : (boolean) $qualified; |
113
|
|
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return bool |
118
|
|
|
*/ |
119
|
|
|
public function isNil() |
120
|
|
|
{ |
121
|
|
|
return $this->nil; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param bool $nil |
126
|
|
|
* |
127
|
|
|
* @return $this |
128
|
|
|
*/ |
129
|
|
|
public function setNil($nil) |
130
|
|
|
{ |
131
|
|
|
$this->nil = is_bool($nil) ? $nil : (boolean) $nil; |
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return ElementRef |
137
|
|
|
*/ |
138
|
135 |
|
public static function loadElementRef( |
139
|
|
|
SchemaReader $reader, |
|
|
|
|
140
|
|
|
ElementDef $referenced, |
141
|
|
|
DOMElement $node |
142
|
|
|
) { |
143
|
135 |
|
$ref = new ElementRef($referenced); |
144
|
135 |
|
$ref->setDoc(SchemaReader::getDocumentation($node)); |
145
|
|
|
|
146
|
135 |
|
SchemaReader::maybeSetMax($ref, $node); |
147
|
135 |
|
SchemaReader::maybeSetMin($ref, $node); |
148
|
135 |
|
if ($node->hasAttribute("nillable")) { |
149
|
|
|
$ref->setNil($node->getAttribute("nillable") == "true"); |
150
|
|
|
} |
151
|
135 |
|
if ($node->hasAttribute("form")) { |
152
|
|
|
$ref->setQualified($node->getAttribute("form") == "qualified"); |
153
|
|
|
} |
154
|
|
|
|
155
|
135 |
|
return $ref; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.