Skip to content

Commit 746b69c

Browse files
Nemo64jderusse
andauthored
implement rds-data service (#645)
* implement RDSDataService * Handle recurcion is JsonRest * Update Services * Update RdsDataService * Fallback endpoint when not available * set FUNCTION_KEY in more places * update readme for value object * php cs fix * implement $fn usage detection * make phpstan ignore array keys that are defined out of order phpstan/phpstan#3358 * revert added complexity by just ignoring phpstan messages * change capitalisation of the rds data service * ignore argument missmatch in generated code * avoid edge case where a function is accessed but not created Co-authored-by: Jérémy Derussé <jeremy@derusse.com>
1 parent ba7cbaa commit 746b69c

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

src/Result/ListLayerVersionsResponse.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,32 +112,34 @@ public function getNextMarker(): ?string
112112
protected function populateResult(Response $response): void
113113
{
114114
$data = $response->toArray();
115-
116-
$this->NextMarker = isset($data['NextMarker']) ? (string) $data['NextMarker'] : null;
117-
$this->LayerVersions = empty($data['LayerVersions']) ? [] : (function (array $json): array {
115+
$fn = [];
116+
$fn['list-LayerVersionsList'] = static function (array $json) use (&$fn): array {
118117
$items = [];
119118
foreach ($json as $item) {
120119
$items[] = new LayerVersionsListItem([
121120
'LayerVersionArn' => isset($item['LayerVersionArn']) ? (string) $item['LayerVersionArn'] : null,
122121
'Version' => isset($item['Version']) ? (string) $item['Version'] : null,
123122
'Description' => isset($item['Description']) ? (string) $item['Description'] : null,
124123
'CreatedDate' => isset($item['CreatedDate']) ? (string) $item['CreatedDate'] : null,
125-
'CompatibleRuntimes' => empty($item['CompatibleRuntimes']) ? [] : (function (array $json): array {
126-
$items = [];
127-
foreach ($json as $item) {
128-
$a = isset($item) ? (string) $item : null;
129-
if (null !== $a) {
130-
$items[] = $a;
131-
}
132-
}
133-
134-
return $items;
135-
})($item['CompatibleRuntimes']),
124+
'CompatibleRuntimes' => empty($item['CompatibleRuntimes']) ? [] : $fn['list-CompatibleRuntimes']($item['CompatibleRuntimes']),
136125
'LicenseInfo' => isset($item['LicenseInfo']) ? (string) $item['LicenseInfo'] : null,
137126
]);
138127
}
139128

140129
return $items;
141-
})($data['LayerVersions']);
130+
};
131+
$fn['list-CompatibleRuntimes'] = static function (array $json) use (&$fn): array {
132+
$items = [];
133+
foreach ($json as $item) {
134+
$a = isset($item) ? (string) $item : null;
135+
if (null !== $a) {
136+
$items[] = $a;
137+
}
138+
}
139+
140+
return $items;
141+
};
142+
$this->NextMarker = isset($data['NextMarker']) ? (string) $data['NextMarker'] : null;
143+
$this->LayerVersions = empty($data['LayerVersions']) ? [] : $fn['list-LayerVersionsList']($data['LayerVersions']);
142144
}
143145
}

src/Result/PublishLayerVersionResponse.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,18 @@ public function getVersion(): ?string
113113
protected function populateResult(Response $response): void
114114
{
115115
$data = $response->toArray();
116+
$fn = [];
117+
$fn['list-CompatibleRuntimes'] = static function (array $json) use (&$fn): array {
118+
$items = [];
119+
foreach ($json as $item) {
120+
$a = isset($item) ? (string) $item : null;
121+
if (null !== $a) {
122+
$items[] = $a;
123+
}
124+
}
116125

126+
return $items;
127+
};
117128
$this->Content = empty($data['Content']) ? null : new LayerVersionContentOutput([
118129
'Location' => isset($data['Content']['Location']) ? (string) $data['Content']['Location'] : null,
119130
'CodeSha256' => isset($data['Content']['CodeSha256']) ? (string) $data['Content']['CodeSha256'] : null,
@@ -124,17 +135,7 @@ protected function populateResult(Response $response): void
124135
$this->Description = isset($data['Description']) ? (string) $data['Description'] : null;
125136
$this->CreatedDate = isset($data['CreatedDate']) ? (string) $data['CreatedDate'] : null;
126137
$this->Version = isset($data['Version']) ? (string) $data['Version'] : null;
127-
$this->CompatibleRuntimes = empty($data['CompatibleRuntimes']) ? [] : (function (array $json): array {
128-
$items = [];
129-
foreach ($json as $item) {
130-
$a = isset($item) ? (string) $item : null;
131-
if (null !== $a) {
132-
$items[] = $a;
133-
}
134-
}
135-
136-
return $items;
137-
})($data['CompatibleRuntimes']);
138+
$this->CompatibleRuntimes = empty($data['CompatibleRuntimes']) ? [] : $fn['list-CompatibleRuntimes']($data['CompatibleRuntimes']);
138139
$this->LicenseInfo = isset($data['LicenseInfo']) ? (string) $data['LicenseInfo'] : null;
139140
}
140141
}

0 commit comments

Comments
 (0)