| 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' => StructureShape::class, 'map' => MapShape::class, 'list' => ListShape::class, 'timestamp' => TimestampShape::class, 'integer' => Shape::class, 'double' => Shape::class, 'float' => Shape::class, 'long' => Shape::class, 'string' => Shape::class, 'byte' => Shape::class, 'character' => Shape::class, 'blob' => Shape::class, 'boolean' => Shape::class]; |
| 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 |
* Get a context param definition. |
| 51 |
*/ |
| 52 |
public function getContextParam() |
| 53 |
{ |
| 54 |
return $this->contextParam; |
| 55 |
} |
| 56 |
} |
| 57 |
|