PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / Api / ShapeMap.php
transferito / vendor / aws / aws-sdk-php / src / Api Last commit date
ErrorParser 11 months ago Parser 11 months ago Serializer 11 months ago AbstractModel.php 11 months ago ApiProvider.php 11 months ago DateTimeResult.php 11 months ago DocModel.php 11 months ago ListShape.php 11 months ago MapShape.php 11 months ago Operation.php 11 months ago Service.php 11 months ago Shape.php 11 months ago ShapeMap.php 11 months ago StructureShape.php 11 months ago TimestampShape.php 11 months ago Validator.php 11 months ago
ShapeMap.php
69 lines
1 <?php
2 namespace Aws\Api;
3
4 /**
5 * Builds shape based on shape references.
6 */
7 class ShapeMap
8 {
9 /** @var array */
10 private $definitions;
11
12 /** @var Shape[] */
13 private $simple;
14
15 /**
16 * @param array $shapeModels Associative array of shape definitions.
17 */
18 public function __construct(array $shapeModels)
19 {
20 $this->definitions = $shapeModels;
21 }
22
23 /**
24 * Get an array of shape names.
25 *
26 * @return array
27 */
28 public function getShapeNames()
29 {
30 return array_keys($this->definitions);
31 }
32
33 /**
34 * Resolve a shape reference
35 *
36 * @param array $shapeRef Shape reference shape
37 *
38 * @return Shape
39 * @throws \InvalidArgumentException
40 */
41 public function resolve(array $shapeRef)
42 {
43 $shape = $shapeRef['shape'];
44
45 if (!isset($this->definitions[$shape])) {
46 throw new \InvalidArgumentException('Shape not found: ' . $shape);
47 }
48
49 $isSimple = count($shapeRef) == 1;
50 if ($isSimple && isset($this->simple[$shape])) {
51 return $this->simple[$shape];
52 }
53
54 $definition = $shapeRef + $this->definitions[$shape];
55 $definition['name'] = $definition['shape'];
56 if (isset($definition['shape'])) {
57 unset($definition['shape']);
58 }
59
60 $result = Shape::create($definition, $this);
61
62 if ($isSimple) {
63 $this->simple[$shape] = $result;
64 }
65
66 return $result;
67 }
68 }
69