Code Duplication    Length = 22-25 lines in 2 locations

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

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