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