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
MapShape.php
55 lines
| 1 | <?php |
| 2 | namespace Aws\Api; |
| 3 | |
| 4 | /** |
| 5 | * Represents a map shape. |
| 6 | */ |
| 7 | class MapShape extends Shape |
| 8 | { |
| 9 | /** @var Shape */ |
| 10 | private $value; |
| 11 | |
| 12 | /** @var Shape */ |
| 13 | private $key; |
| 14 | |
| 15 | public function __construct(array $definition, ShapeMap $shapeMap) |
| 16 | { |
| 17 | $definition['type'] = 'map'; |
| 18 | parent::__construct($definition, $shapeMap); |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * @return Shape |
| 23 | * @throws \RuntimeException if no value is specified |
| 24 | */ |
| 25 | public function getValue() |
| 26 | { |
| 27 | if (!$this->value) { |
| 28 | if (!isset($this->definition['value'])) { |
| 29 | throw new \RuntimeException('No value specified'); |
| 30 | } |
| 31 | |
| 32 | $this->value = Shape::create( |
| 33 | $this->definition['value'], |
| 34 | $this->shapeMap |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | return $this->value; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @return Shape |
| 43 | */ |
| 44 | public function getKey() |
| 45 | { |
| 46 | if (!$this->key) { |
| 47 | $this->key = isset($this->definition['key']) |
| 48 | ? Shape::create($this->definition['key'], $this->shapeMap) |
| 49 | : new Shape(['type' => 'string'], $this->shapeMap); |
| 50 | } |
| 51 | |
| 52 | return $this->key; |
| 53 | } |
| 54 | } |
| 55 |