|
4 | 4 |
|
5 | 5 | use AsyncAws\Core\Response;
|
6 | 6 | use AsyncAws\Core\Result;
|
| 7 | +use AsyncAws\Lambda\Enum\Runtime; |
7 | 8 | use AsyncAws\Lambda\Input\ListLayerVersionsRequest;
|
8 | 9 | use AsyncAws\Lambda\LambdaClient;
|
9 | 10 | use AsyncAws\Lambda\ValueObject\LayerVersionsListItem;
|
@@ -112,34 +113,44 @@ public function getNextMarker(): ?string
|
112 | 113 | protected function populateResult(Response $response): void
|
113 | 114 | {
|
114 | 115 | $data = $response->toArray();
|
115 |
| - $fn = []; |
116 |
| - $fn['list-LayerVersionsList'] = static function (array $json) use (&$fn): array { |
117 |
| - $items = []; |
118 |
| - foreach ($json as $item) { |
119 |
| - $items[] = new LayerVersionsListItem([ |
120 |
| - 'LayerVersionArn' => isset($item['LayerVersionArn']) ? (string) $item['LayerVersionArn'] : null, |
121 |
| - 'Version' => isset($item['Version']) ? (string) $item['Version'] : null, |
122 |
| - 'Description' => isset($item['Description']) ? (string) $item['Description'] : null, |
123 |
| - 'CreatedDate' => isset($item['CreatedDate']) ? (string) $item['CreatedDate'] : null, |
124 |
| - 'CompatibleRuntimes' => empty($item['CompatibleRuntimes']) ? [] : $fn['list-CompatibleRuntimes']($item['CompatibleRuntimes']), |
125 |
| - 'LicenseInfo' => isset($item['LicenseInfo']) ? (string) $item['LicenseInfo'] : null, |
126 |
| - ]); |
127 |
| - } |
128 | 116 |
|
129 |
| - return $items; |
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 |
| - } |
| 117 | + $this->NextMarker = isset($data['NextMarker']) ? (string) $data['NextMarker'] : null; |
| 118 | + $this->LayerVersions = empty($data['LayerVersions']) ? [] : $this->populateResultLayerVersionsList($data['LayerVersions']); |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * @return list<Runtime::*> |
| 123 | + */ |
| 124 | + private function populateResultCompatibleRuntimes(array $json): array |
| 125 | + { |
| 126 | + $items = []; |
| 127 | + foreach ($json as $item) { |
| 128 | + $a = isset($item) ? (string) $item : null; |
| 129 | + if (null !== $a) { |
| 130 | + $items[] = $a; |
138 | 131 | }
|
| 132 | + } |
139 | 133 |
|
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']); |
| 134 | + return $items; |
| 135 | + } |
| 136 | + |
| 137 | + /** |
| 138 | + * @return LayerVersionsListItem[] |
| 139 | + */ |
| 140 | + private function populateResultLayerVersionsList(array $json): array |
| 141 | + { |
| 142 | + $items = []; |
| 143 | + foreach ($json as $item) { |
| 144 | + $items[] = new LayerVersionsListItem([ |
| 145 | + 'LayerVersionArn' => isset($item['LayerVersionArn']) ? (string) $item['LayerVersionArn'] : null, |
| 146 | + 'Version' => isset($item['Version']) ? (string) $item['Version'] : null, |
| 147 | + 'Description' => isset($item['Description']) ? (string) $item['Description'] : null, |
| 148 | + 'CreatedDate' => isset($item['CreatedDate']) ? (string) $item['CreatedDate'] : null, |
| 149 | + 'CompatibleRuntimes' => empty($item['CompatibleRuntimes']) ? [] : $this->populateResultCompatibleRuntimes($item['CompatibleRuntimes']), |
| 150 | + 'LicenseInfo' => isset($item['LicenseInfo']) ? (string) $item['LicenseInfo'] : null, |
| 151 | + ]); |
| 152 | + } |
| 153 | + |
| 154 | + return $items; |
144 | 155 | }
|
145 | 156 | }
|
0 commit comments