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 / Shape.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
Shape.php
78 lines
1 <?php
2 namespace Aws\Api;
3
4 /**
5 * Base class representing a modeled shape.
6 */
7 class Shape extends AbstractModel
8 {
9 /**
10 * Get a concrete shape for the given definition.
11 *
12 * @param array $definition
13 * @param ShapeMap $shapeMap
14 *
15 * @return mixed
16 * @throws \RuntimeException if the type is invalid
17 */
18 public static function create(array $definition, ShapeMap $shapeMap)
19 {
20 static $map = [
21 'structure' => StructureShape::class,
22 'map' => MapShape::class,
23 'list' => ListShape::class,
24 'timestamp' => TimestampShape::class,
25 'integer' => Shape::class,
26 'double' => Shape::class,
27 'float' => Shape::class,
28 'long' => Shape::class,
29 'string' => Shape::class,
30 'byte' => Shape::class,
31 'character' => Shape::class,
32 'blob' => Shape::class,
33 'boolean' => Shape::class
34 ];
35
36 if (isset($definition['shape'])) {
37 return $shapeMap->resolve($definition);
38 }
39
40 if (!isset($map[$definition['type']])) {
41 throw new \RuntimeException('Invalid type: '
42 . print_r($definition, true));
43 }
44
45 $type = $map[$definition['type']];
46
47 return new $type($definition, $shapeMap);
48 }
49
50 /**
51 * Get the type of the shape
52 *
53 * @return string
54 */
55 public function getType()
56 {
57 return $this->definition['type'];
58 }
59
60 /**
61 * Get the name of the shape
62 *
63 * @return string
64 */
65 public function getName()
66 {
67 return $this->definition['name'];
68 }
69
70 /**
71 * Get a context param definition.
72 */
73 public function getContextParam()
74 {
75 return $this->contextParam;
76 }
77 }
78