@@ -182,26 +182,40 @@ private function generatePopulator(Operation $operation, StructureShape $shape,
182
182
$ locationName = strtolower ($ member ->getLocationName () ?? $ member ->getName ());
183
183
$ propertyName = GeneratorHelper::normalizeName ($ member ->getName ());
184
184
$ memberShape = $ member ->getShape ();
185
- if ('timestamp ' === $ memberShape ->getType ()) {
186
- $ body .= strtr ('$this->PROPERTY_NAME = isset($headers["LOCATION_NAME"][0]) ? new \DateTimeImmutable($headers["LOCATION_NAME"][0]) : null; ' . "\n" , [
187
- 'PROPERTY_NAME ' => $ propertyName ,
188
- 'LOCATION_NAME ' => $ locationName ,
189
- ]);
190
- } else {
191
- if (null !== $ constant = $ this ->typeGenerator ->getFilterConstant ($ memberShape )) {
185
+ switch ($ memberShape ->getType ()) {
186
+ case 'timestamp ' :
187
+ $ body .= strtr ('$this->PROPERTY_NAME = isset($headers["LOCATION_NAME"][0]) ? new \DateTimeImmutable($headers["LOCATION_NAME"][0]) : null; ' . "\n" , [
188
+ 'PROPERTY_NAME ' => $ propertyName ,
189
+ 'LOCATION_NAME ' => $ locationName ,
190
+ ]);
191
+
192
+ break ;
193
+ case 'integer ' :
194
+ case 'long ' :
195
+ $ body .= strtr ('$this->PROPERTY_NAME = isset($headers["LOCATION_NAME"][0]) ? (int) $headers["LOCATION_NAME"][0] : null; ' . "\n" , [
196
+ 'PROPERTY_NAME ' => $ propertyName ,
197
+ 'LOCATION_NAME ' => $ locationName ,
198
+ ]);
199
+
200
+ break ;
201
+ case 'boolean ' :
192
202
$ this ->requirementsRegistry ->addRequirement ('ext-filter ' );
193
203
194
- $ body .= strtr ('$this->PROPERTY_NAME = isset($headers["LOCATION_NAME"][0]) ? filter_var($headers["LOCATION_NAME"][0], FILTER ) : null; ' . "\n" , [
204
+ $ body .= strtr ('$this->PROPERTY_NAME = isset($headers["LOCATION_NAME"][0]) ? filter_var($headers["LOCATION_NAME"][0], FILTER_VALIDATE_BOOLEAN ) : null; ' . "\n" , [
195
205
'PROPERTY_NAME ' => $ propertyName ,
196
206
'LOCATION_NAME ' => $ locationName ,
197
- 'FILTER ' => $ constant ,
198
207
]);
199
- } else {
208
+
209
+ break ;
210
+ case 'string ' :
200
211
$ body .= strtr ('$this->PROPERTY_NAME = $headers["LOCATION_NAME"][0] ?? null; ' . "\n" , [
201
212
'PROPERTY_NAME ' => $ propertyName ,
202
213
'LOCATION_NAME ' => $ locationName ,
203
214
]);
204
- }
215
+
216
+ break ;
217
+ default :
218
+ throw new \RuntimeException (sprintf ('Type %s is not yet implemented ' , $ memberShape ->getType ()));
205
219
}
206
220
}
207
221
0 commit comments