Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,39 +190,36 @@ private function generatePopulator(Operation $operation, StructureShape $shape,
$memberShape = $member->getShape();
switch ($memberShape->getType()) {
case 'timestamp':
$body .= strtr('$this->PROPERTY_NAME = isset($headers["LOCATION_NAME"][0]) ? new \DateTimeImmutable($headers["LOCATION_NAME"][0]) : null;' . "\n", [
'PROPERTY_NAME' => $propertyName,
'LOCATION_NAME' => $locationName,
]);
$input = 'new \DateTimeImmutable($headers["LOCATION_NAME"][0])';

break;
case 'integer':
case 'long':
$body .= strtr('$this->PROPERTY_NAME = isset($headers["LOCATION_NAME"][0]) ? (int) $headers["LOCATION_NAME"][0] : null;' . "\n", [
'PROPERTY_NAME' => $propertyName,
'LOCATION_NAME' => $locationName,
]);
$input = '(int) $headers["LOCATION_NAME"][0]';

break;
case 'boolean':
$this->requirementsRegistry->addRequirement('ext-filter');

$body .= strtr('$this->PROPERTY_NAME = isset($headers["LOCATION_NAME"][0]) ? filter_var($headers["LOCATION_NAME"][0], FILTER_VALIDATE_BOOLEAN) : null;' . "\n", [
'PROPERTY_NAME' => $propertyName,
'LOCATION_NAME' => $locationName,
]);
$input = 'filter_var($headers["LOCATION_NAME"][0], FILTER_VALIDATE_BOOLEAN)';

break;
case 'string':
$body .= strtr('$this->PROPERTY_NAME = $headers["LOCATION_NAME"][0] ?? null;' . "\n", [
'PROPERTY_NAME' => $propertyName,
'LOCATION_NAME' => $locationName,
]);
$input = '$headers["LOCATION_NAME"][0]';

break;
default:
throw new \RuntimeException(sprintf('Type %s is not yet implemented', $memberShape->getType()));
}

if (!$member->isRequired()) {
$input = 'isset($headers["LOCATION_NAME"][0]) ? ' . $input . ' : null';
}

$body .= strtr('$this->PROPERTY_NAME = ' . $input . ";\n", [
'PROPERTY_NAME' => $propertyName,
'LOCATION_NAME' => $locationName,
]);
}

// This will catch arbitrary values that exists in undefined "headers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function populateResult(Response $response): void
{
$headers = $response->getHeaders();

$this->location = $headers['location'][0] ?? null;
$this->location = $headers['location'][0];

$data = new \SimpleXMLElement($response->getContent());
$this->hostedZone = new HostedZone([
Expand Down