Exemplo n.º 1
0
 public static function create(array $definition, ShapeMap $shapeMap)
 {
     static $map = ['structure' => [], 'map' => [], 'list' => [], 'timestamp' => [], 'integer' => [], 'double' => [], 'float' => [], 'long' => [], 'string' => [], 'byte' => [], 'character' => [], 'blob' => [], 'boolean' => []];
     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);
 }
Exemplo n.º 2
0
 protected function shapeFor(array $definition)
 {
     return isset($definition['shape']) ? $this->shapeMap->resolve($definition) : Shape::create($definition, $this->shapeMap);
 }