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