Code Duplication    Length = 13-13 lines in 2 locations

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

@@ 1251-1263 (lines=13) @@
1248
     *
1249
     * @throws TDBMException
1250
     */
1251
    public function findObject(string $mainTable, $filter = null, array $parameters = array(), array $additionalTablesFetch = array(), string $className = null)
1252
    {
1253
        $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className);
1254
        $page = $objects->take(0, 2);
1255
        $count = $page->count();
1256
        if ($count > 1) {
1257
            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.");
1258
        } elseif ($count === 0) {
1259
            return;
1260
        }
1261
1262
        return $page[0];
1263
    }
1264
1265
    /**
1266
     * Returns a unique bean (or null) according to the filters passed in parameter.
@@ 1278-1290 (lines=13) @@
1275
     *
1276
     * @throws TDBMException
1277
     */
1278
    public function findObjectFromSql($mainTable, $from, $filter = null, array $parameters = array(), $className = null)
1279
    {
1280
        $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className);
1281
        $page = $objects->take(0, 2);
1282
        $count = $page->count();
1283
        if ($count > 1) {
1284
            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.");
1285
        } elseif ($count === 0) {
1286
            return;
1287
        }
1288
1289
        return $page[0];
1290
    }
1291
1292
    /**
1293
     * Returns a unique bean according to the filters passed in parameter.