/** * @return DB */ public function add(AbstractModel $model) { if ($this->identityMap->hasIdentityKey($model)) { $model = $this->identityMap->get($model); } else { $this->new->attach($model); } $this->attach($model); return $this; }
/** * @covers IdentityMap::getId * @depends testObjectCanBeAdded * @expectedException OutOfBoundsException */ public function testExceptionIsRaisedForNonExistantObject(IdentityMap $map) { $map->getId(new StdClass()); }
protected function toIdentityMap(EntityInterface $entity) { $this->getIdentityMap()->offsetSet($entity->getId(), $entity); $this->identityMapOriginal->offsetSet($entity->getId(), clone $entity); }