public function __construct(ObjectSchema $object_schema, $id = null, Neo4j\PropertyContainer $client_object = null) { $this->schema = $object_schema; $this->client = $object_schema->getClient(); if ($client_object) { if ($client_object->getId() !== $id) { throw new \InvalidArgumentException('IDs do not match.'); } $this->client_object = $client_object; $this->id = $id; } else { if (is_int($id) or ctype_digit($id)) { $this->id = (int) $id; } else { if ($id) { throw new \InvalidArgumentException('Invalid ID.'); } } } }
/** * Determine the cache key used to retrieve the given entity from the cache * * @param PropertyContainer $entity * @return string */ protected function getEntityCacheKey(PropertyContainer $entity) { if ($entity instanceof Node) { return 'node-' . $entity->getId(); } else { if ($entity instanceof Relationship) { return 'relationship-' . $entity->getId(); } } throw new Exception('Unknown entity type: ' . get_class($entity)); }