Code Duplication    Length = 13-13 lines in 2 locations

src/Mouf/Database/TDBM/TDBMService.php 2 locations

@@ 1611-1623 (lines=13) @@
1608
     *
1609
     * @throws TDBMException
1610
     */
1611
    public function findObject(string $mainTable, $filter = null, array $parameters = array(), array $additionalTablesFetch = array(), string $className = null)
1612
    {
1613
        $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className);
1614
        $page = $objects->take(0, 2);
1615
        $count = $page->count();
1616
        if ($count > 1) {
1617
            throw new DuplicateRowException("Error while querying an object for table '$mainTable': More than 1 row have been returned, but we should have received at most one.");
1618
        } elseif ($count === 0) {
1619
            return;
1620
        }
1621
1622
        return $page[0];
1623
    }
1624
1625
    /**
1626
     * Returns a unique bean (or null) according to the filters passed in parameter.
@@ 1638-1650 (lines=13) @@
1635
     *
1636
     * @throws TDBMException
1637
     */
1638
    public function findObjectFromSql($mainTable, $from, $filter = null, array $parameters = array(), $className = null)
1639
    {
1640
        $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className);
1641
        $page = $objects->take(0, 2);
1642
        $count = $page->count();
1643
        if ($count > 1) {
1644
            throw new DuplicateRowException("Error while querying an object for table '$mainTable': More than 1 row have been returned, but we should have received at most one.");
1645
        } elseif ($count === 0) {
1646
            return;
1647
        }
1648
1649
        return $page[0];
1650
    }
1651
1652
    /**
1653
     * Returns a unique bean according to the filters passed in parameter.