Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
}