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); }
protected function shapeFor(array $definition) { return isset($definition['shape']) ? $this->shapeMap->resolve($definition) : Shape::create($definition, $this->shapeMap); }