Code Duplication    Length = 13-13 lines in 2 locations

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

@@ 1381-1393 (lines=13) @@
1378
     *
1379
     * @throws TDBMException
1380
     */
1381
    public function findObject(string $mainTable, $filter = null, array $parameters = array(), array $additionalTablesFetch = array(), string $className = null)
1382
    {
1383
        $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className);
1384
        $page = $objects->take(0, 2);
1385
        $count = $page->count();
1386
        if ($count > 1) {
1387
            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.");
1388
        } elseif ($count === 0) {
1389
            return;
1390
        }
1391
1392
        return $page[0];
1393
    }
1394
1395
    /**
1396
     * Returns a unique bean (or null) according to the filters passed in parameter.
@@ 1408-1420 (lines=13) @@
1405
     *
1406
     * @throws TDBMException
1407
     */
1408
    public function findObjectFromSql($mainTable, $from, $filter = null, array $parameters = array(), $className = null)
1409
    {
1410
        $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className);
1411
        $page = $objects->take(0, 2);
1412
        $count = $page->count();
1413
        if ($count > 1) {
1414
            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.");
1415
        } elseif ($count === 0) {
1416
            return;
1417
        }
1418
1419
        return $page[0];
1420
    }
1421
1422
    /**
1423
     * Returns a unique bean according to the filters passed in parameter.