Code Duplication    Length = 20-23 lines in 3 locations

eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php 3 locations

@@ 1323-1345 (lines=23) @@
1320
     *
1321
     * @return int Number of affected rows.
1322
     */
1323
    public function deleteUrlAliasesWithoutParent(): int
1324
    {
1325
        $existingAliasesQuery = $this->getAllUrlAliasesQuery();
1326
1327
        $query = $this->connection->createQueryBuilder();
1328
        $query
1329
            ->delete($this->table)
1330
            ->where(
1331
                $query->expr()->neq(
1332
                    'parent',
1333
                    $query->createPositionalParameter(0, \PDO::PARAM_INT)
1334
                )
1335
            )
1336
            ->andWhere(
1337
                $query->expr()->notIn(
1338
                    'parent',
1339
                    $existingAliasesQuery
1340
                )
1341
            )
1342
        ;
1343
1344
        return $query->execute();
1345
    }
1346
1347
    /**
1348
     * Delete URL aliases which do not link to any existing URL alias node.
@@ 1352-1371 (lines=20) @@
1349
     *
1350
     * Note: Typically link column value is used to determine original alias for an archived entries.
1351
     */
1352
    public function deleteUrlAliasesWithBrokenLink()
1353
    {
1354
        $existingAliasesQuery = $this->getAllUrlAliasesQuery();
1355
1356
        $query = $this->connection->createQueryBuilder();
1357
        $query
1358
            ->delete($this->table)
1359
            ->where(
1360
                $query->expr()->neq('id', 'link')
1361
            )
1362
            ->andWhere(
1363
                $query->expr()->notIn(
1364
                    'link',
1365
                    $existingAliasesQuery
1366
                )
1367
            )
1368
        ;
1369
1370
        return $query->execute();
1371
    }
1372
1373
    /**
1374
     * Attempt repairing data corruption for broken archived URL aliases for Location,
@@ 1499-1520 (lines=22) @@
1496
    /**
1497
     * @throws \Doctrine\DBAL\DBALException
1498
     */
1499
    public function getAllChildrenAliases(int $parentId): array
1500
    {
1501
        $queryBuilder = $this->connection->createQueryBuilder();
1502
        $expressionBuilder = $queryBuilder->expr();
1503
1504
        $queryBuilder
1505
            ->select('*')
1506
            ->from($this->table)
1507
            ->where(
1508
                $expressionBuilder->eq(
1509
                    'parent',
1510
                    $queryBuilder->createPositionalParameter($parentId, ParameterType::INTEGER)
1511
                )
1512
            )->andWhere(
1513
                $expressionBuilder->eq(
1514
                    'is_alias',
1515
                    $queryBuilder->createPositionalParameter(1, ParameterType::INTEGER)
1516
                )
1517
            );
1518
1519
        return $queryBuilder->execute()->fetchAll();
1520
    }
1521
1522
    /**
1523
     * Filter from the given result set original (current) only URL aliases and index them by language_mask.