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