mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-14 10:37:19 -07:00
spaces.php
This commit is contained in:
parent
7755490b81
commit
eefa32741e
845 changed files with 50409 additions and 0 deletions
69
aws/Aws/Api/Shape.php
Normal file
69
aws/Aws/Api/Shape.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
namespace Aws\Api;
|
||||
|
||||
/**
|
||||
* Base class representing a modeled shape.
|
||||
*/
|
||||
class Shape extends AbstractModel
|
||||
{
|
||||
/**
|
||||
* Get a concrete shape for the given definition.
|
||||
*
|
||||
* @param array $definition
|
||||
* @param ShapeMap $shapeMap
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \RuntimeException if the type is invalid
|
||||
*/
|
||||
public static function create(array $definition, ShapeMap $shapeMap)
|
||||
{
|
||||
static $map = [
|
||||
'structure' => 'Aws\Api\StructureShape',
|
||||
'map' => 'Aws\Api\MapShape',
|
||||
'list' => 'Aws\Api\ListShape',
|
||||
'timestamp' => 'Aws\Api\TimestampShape',
|
||||
'integer' => 'Aws\Api\Shape',
|
||||
'double' => 'Aws\Api\Shape',
|
||||
'float' => 'Aws\Api\Shape',
|
||||
'long' => 'Aws\Api\Shape',
|
||||
'string' => 'Aws\Api\Shape',
|
||||
'byte' => 'Aws\Api\Shape',
|
||||
'character' => 'Aws\Api\Shape',
|
||||
'blob' => 'Aws\Api\Shape',
|
||||
'boolean' => 'Aws\Api\Shape'
|
||||
];
|
||||
|
||||
if (isset($definition['shape'])) {
|
||||
return $shapeMap->resolve($definition);
|
||||
}
|
||||
|
||||
if (!isset($map[$definition['type']])) {
|
||||
throw new \RuntimeException('Invalid type: '
|
||||
. print_r($definition, true));
|
||||
}
|
||||
|
||||
$type = $map[$definition['type']];
|
||||
|
||||
return new $type($definition, $shapeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the shape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->definition['type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the shape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->definition['name'];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue