Code Duplication    Length = 13-13 lines in 2 locations

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

@@ 1612-1624 (lines=13) @@
1609
     *
1610
     * @throws TDBMException
1611
     */
1612
    public function findObject(string $mainTable, $filter = null, array $parameters = array(), array $additionalTablesFetch = array(), string $className = null)
1613
    {
1614
        $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className);
1615
        $page = $objects->take(0, 2);
1616
        $count = $page->count();
1617
        if ($count > 1) {
1618
            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.");
1619
        } elseif ($count === 0) {
1620
            return;
1621
        }
1622
1623
        return $page[0];
1624
    }
1625
1626
    /**
1627
     * Returns a unique bean (or null) according to the filters passed in parameter.
@@ 1639-1651 (lines=13) @@
1636
     *
1637
     * @throws TDBMException
1638
     */
1639
    public function findObjectFromSql($mainTable, $from, $filter = null, array $parameters = array(), $className = null)
1640
    {
1641
        $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className);
1642
        $page = $objects->take(0, 2);
1643
        $count = $page->count();
1644
        if ($count > 1) {
1645
            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.");
1646
        } elseif ($count === 0) {
1647
            return;
1648
        }
1649
1650
        return $page[0];
1651
    }
1652
1653
    /**
1654
     * Returns a unique bean according to the filters passed in parameter.