Code Duplication    Length = 22-25 lines in 2 locations

application/modules/xbanners/models/Base/Banners.php 2 locations

@@ 1491-1512 (lines=22) @@
1488
     * @param      ConnectionInterface $con Optional connection object
1489
     * @return $this|ChildBanners The current object (for fluent API support)
1490
     */
1491
    public function setBannerImages(Collection $bannerImages, ConnectionInterface $con = null)
1492
    {
1493
        /** @var ChildBannerImage[] $bannerImagesToDelete */
1494
        $bannerImagesToDelete = $this->getBannerImages(new Criteria(), $con)->diff($bannerImages);
1495
1496
1497
        $this->bannerImagesScheduledForDeletion = $bannerImagesToDelete;
1498
1499
        foreach ($bannerImagesToDelete as $bannerImageRemoved) {
1500
            $bannerImageRemoved->setBanners(null);
1501
        }
1502
1503
        $this->collBannerImages = null;
1504
        foreach ($bannerImages as $bannerImage) {
1505
            $this->addBannerImage($bannerImage);
1506
        }
1507
1508
        $this->collBannerImages = $bannerImages;
1509
        $this->collBannerImagesPartial = false;
1510
1511
        return $this;
1512
    }
1513
1514
    /**
1515
     * Returns the number of related BannerImage objects.
@@ 1716-1740 (lines=25) @@
1713
     * @param      ConnectionInterface $con Optional connection object
1714
     * @return $this|ChildBanners The current object (for fluent API support)
1715
     */
1716
    public function setBannersI18ns(Collection $bannersI18ns, ConnectionInterface $con = null)
1717
    {
1718
        /** @var ChildBannersI18n[] $bannersI18nsToDelete */
1719
        $bannersI18nsToDelete = $this->getBannersI18ns(new Criteria(), $con)->diff($bannersI18ns);
1720
1721
1722
        //since at least one column in the foreign key is at the same time a PK
1723
        //we can not just set a PK to NULL in the lines below. We have to store
1724
        //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
1725
        $this->bannersI18nsScheduledForDeletion = clone $bannersI18nsToDelete;
1726
1727
        foreach ($bannersI18nsToDelete as $bannersI18nRemoved) {
1728
            $bannersI18nRemoved->setBanners(null);
1729
        }
1730
1731
        $this->collBannersI18ns = null;
1732
        foreach ($bannersI18ns as $bannersI18n) {
1733
            $this->addBannersI18n($bannersI18n);
1734
        }
1735
1736
        $this->collBannersI18ns = $bannersI18ns;
1737
        $this->collBannersI18nsPartial = false;
1738
1739
        return $this;
1740
    }
1741
1742
    /**
1743
     * Returns the number of related BannersI18n objects.