Code Duplication    Length = 22-22 lines in 5 locations

src/cli/Database/Base/User.php 2 locations

@@ 1387-1408 (lines=22) @@
1384
     * @param      ConnectionInterface $con Optional connection object
1385
     * @return $this|ChildUser The current object (for fluent API support)
1386
     */
1387
    public function setConnections(Collection $connections, ConnectionInterface $con = null)
1388
    {
1389
        /** @var ChildConnection[] $connectionsToDelete */
1390
        $connectionsToDelete = $this->getConnections(new Criteria(), $con)->diff($connections);
1391
1392
1393
        $this->connectionsScheduledForDeletion = $connectionsToDelete;
1394
1395
        foreach ($connectionsToDelete as $connectionRemoved) {
1396
            $connectionRemoved->setUser(null);
1397
        }
1398
1399
        $this->collConnections = null;
1400
        foreach ($connections as $connection) {
1401
            $this->addConnection($connection);
1402
        }
1403
1404
        $this->collConnections = $connections;
1405
        $this->collConnectionsPartial = false;
1406
1407
        return $this;
1408
    }
1409
1410
    /**
1411
     * Returns the number of related Connection objects.
@@ 1637-1658 (lines=22) @@
1634
     * @param      ConnectionInterface $con Optional connection object
1635
     * @return $this|ChildUser The current object (for fluent API support)
1636
     */
1637
    public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null)
1638
    {
1639
        /** @var ChildSubscription[] $subscriptionsToDelete */
1640
        $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions);
1641
1642
1643
        $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete;
1644
1645
        foreach ($subscriptionsToDelete as $subscriptionRemoved) {
1646
            $subscriptionRemoved->setUser(null);
1647
        }
1648
1649
        $this->collSubscriptions = null;
1650
        foreach ($subscriptions as $subscription) {
1651
            $this->addSubscription($subscription);
1652
        }
1653
1654
        $this->collSubscriptions = $subscriptions;
1655
        $this->collSubscriptionsPartial = false;
1656
1657
        return $this;
1658
    }
1659
1660
    /**
1661
     * Returns the number of related Subscription objects.

src/cli/Database/Base/Input.php 1 location

@@ 1573-1594 (lines=22) @@
1570
     * @param      ConnectionInterface $con Optional connection object
1571
     * @return $this|ChildInput The current object (for fluent API support)
1572
     */
1573
    public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null)
1574
    {
1575
        /** @var ChildSubscription[] $subscriptionsToDelete */
1576
        $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions);
1577
1578
1579
        $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete;
1580
1581
        foreach ($subscriptionsToDelete as $subscriptionRemoved) {
1582
            $subscriptionRemoved->setInput(null);
1583
        }
1584
1585
        $this->collSubscriptions = null;
1586
        foreach ($subscriptions as $subscription) {
1587
            $this->addSubscription($subscription);
1588
        }
1589
1590
        $this->collSubscriptions = $subscriptions;
1591
        $this->collSubscriptionsPartial = false;
1592
1593
        return $this;
1594
    }
1595
1596
    /**
1597
     * Returns the number of related Subscription objects.

src/cli/Database/Base/Instance.php 2 locations

@@ 1560-1581 (lines=22) @@
1557
     * @param      ConnectionInterface $con Optional connection object
1558
     * @return $this|ChildInstance The current object (for fluent API support)
1559
     */
1560
    public function setConnections(Collection $connections, ConnectionInterface $con = null)
1561
    {
1562
        /** @var ChildConnection[] $connectionsToDelete */
1563
        $connectionsToDelete = $this->getConnections(new Criteria(), $con)->diff($connections);
1564
1565
1566
        $this->connectionsScheduledForDeletion = $connectionsToDelete;
1567
1568
        foreach ($connectionsToDelete as $connectionRemoved) {
1569
            $connectionRemoved->setInstance(null);
1570
        }
1571
1572
        $this->collConnections = null;
1573
        foreach ($connections as $connection) {
1574
            $this->addConnection($connection);
1575
        }
1576
1577
        $this->collConnections = $connections;
1578
        $this->collConnectionsPartial = false;
1579
1580
        return $this;
1581
    }
1582
1583
    /**
1584
     * Returns the number of related Connection objects.
@@ 1810-1831 (lines=22) @@
1807
     * @param      ConnectionInterface $con Optional connection object
1808
     * @return $this|ChildInstance The current object (for fluent API support)
1809
     */
1810
    public function setInputs(Collection $inputs, ConnectionInterface $con = null)
1811
    {
1812
        /** @var ChildInput[] $inputsToDelete */
1813
        $inputsToDelete = $this->getInputs(new Criteria(), $con)->diff($inputs);
1814
1815
1816
        $this->inputsScheduledForDeletion = $inputsToDelete;
1817
1818
        foreach ($inputsToDelete as $inputRemoved) {
1819
            $inputRemoved->setInstance(null);
1820
        }
1821
1822
        $this->collInputs = null;
1823
        foreach ($inputs as $input) {
1824
            $this->addInput($input);
1825
        }
1826
1827
        $this->collInputs = $inputs;
1828
        $this->collInputsPartial = false;
1829
1830
        return $this;
1831
    }
1832
1833
    /**
1834
     * Returns the number of related Input objects.