/** * Hydrate a Collection from an Gremlin response * * @param array $row a single row from result set to map. * * @return Collection */ protected function arrayToCollection(array $row) { // Or we map a single record to a Spider Record $collection = new Collection(); //If we're in a classic vertex/edge scenario lets do the following: if (isset($row['properties'])) { foreach ($row['properties'] as $key => $value) { $collection->add($key, $value[0]['value']); } foreach ($row as $key => $value) { if ($key != "properties") { $collection->add('meta.' . $key, $value); } } $collection->add(['id' => $collection->meta()->id, 'label' => $collection->meta()->label]); $collection->protect('id'); $collection->protect('label'); $collection->protect('meta'); } else { //in any other situation lets just map directly to the collection. $collection->add($row); } return $collection; }