Code Duplication    Length = 19-23 lines in 2 locations

lib/Doctrine/ORM/UnitOfWork.php 2 locations

@@ 1423-1441 (lines=19) @@
1420
     *
1421
     * @throws ORMInvalidArgumentException
1422
     */
1423
    public function addToIdentityMap($entity)
1424
    {
1425
        $classMetadata = $this->em->getClassMetadata(get_class($entity));
1426
        $idHash        = implode(' ', $this->entityIdentifiers[spl_object_hash($entity)]);
1427
1428
        if ($idHash === '') {
1429
            throw ORMInvalidArgumentException::entityWithoutIdentity($classMetadata->name, $entity);
1430
        }
1431
1432
        $className = $classMetadata->rootEntityName;
1433
1434
        if (isset($this->identityMap[$className][$idHash])) {
1435
            return false;
1436
        }
1437
1438
        $this->identityMap[$className][$idHash] = $entity;
1439
1440
        return true;
1441
    }
1442
1443
    /**
1444
     * Gets the state of an entity with regard to the current unit of work.
@@ 1537-1559 (lines=23) @@
1534
     *
1535
     * @throws ORMInvalidArgumentException
1536
     */
1537
    public function removeFromIdentityMap($entity)
1538
    {
1539
        $oid           = spl_object_hash($entity);
1540
        $classMetadata = $this->em->getClassMetadata(get_class($entity));
1541
        $idHash        = implode(' ', $this->entityIdentifiers[$oid]);
1542
1543
        if ($idHash === '') {
1544
            throw ORMInvalidArgumentException::entityHasNoIdentity($entity, "remove from identity map");
1545
        }
1546
1547
        $className = $classMetadata->rootEntityName;
1548
1549
        if (isset($this->identityMap[$className][$idHash])) {
1550
            unset($this->identityMap[$className][$idHash]);
1551
            unset($this->readOnlyObjects[$oid]);
1552
1553
            //$this->entityStates[$oid] = self::STATE_DETACHED;
1554
1555
            return true;
1556
        }
1557
1558
        return false;
1559
    }
1560
1561
    /**
1562
     * INTERNAL: