Code Duplication    Length = 5-10 lines in 4 locations

eZ/Publish/Core/Repository/ContentService.php 4 locations

@@ 1517-1523 (lines=7) @@
1514
            );
1515
        }
1516
1517
        if (!$this->repository->canUser('content', 'versionremove', $versionInfo)) {
1518
            throw new UnauthorizedException(
1519
                'content',
1520
                'versionremove',
1521
                array('contentId' => $versionInfo->contentInfo->id, 'versionNo' => $versionInfo->versionNo)
1522
            );
1523
        }
1524
1525
        $versionList = $this->persistenceHandler->contentHandler()->listVersions(
1526
            $versionInfo->contentInfo->id,
@@ 1598-1607 (lines=10) @@
1595
        $destinationLocation = $this->repository->getLocationService()->loadLocation(
1596
            $destinationLocationCreateStruct->parentLocationId
1597
        );
1598
        if (!$this->repository->canUser('content', 'create', $contentInfo, [$destinationLocation])) {
1599
            throw new UnauthorizedException(
1600
                'content',
1601
                'create',
1602
                [
1603
                    'parentLocationId' => $destinationLocationCreateStruct->parentLocationId,
1604
                    'sectionId' => $contentInfo->sectionId,
1605
                ]
1606
            );
1607
        }
1608
1609
        $defaultObjectStates = $this->getDefaultObjectStates();
1610
@@ 1910-1919 (lines=10) @@
1907
        $singleLangVersions = [];
1908
        foreach ($this->loadVersions($contentInfo) as $versionInfo) {
1909
            // check if user is authorized to delete Version
1910
            if (!$this->repository->canUser('content', 'remove', $versionInfo)) {
1911
                throw new UnauthorizedException(
1912
                    'content',
1913
                    'remove',
1914
                    [
1915
                        'contentId' => $contentInfo->id,
1916
                        'versionNo' => $versionInfo->versionNo,
1917
                    ]
1918
                );
1919
            }
1920
            // check if the specified translation exists for the Version
1921
            if (!in_array($languageCode, $versionInfo->languageCodes)) {
1922
                // if translation does not exist, simply ignore Version (see InvalidArgumentException later on)
@@ 2006-2010 (lines=5) @@
2003
            );
2004
        }
2005
2006
        if (!$this->repository->canUser('content', 'edit', $versionInfo->contentInfo)) {
2007
            throw new UnauthorizedException(
2008
                'content', 'edit', ['contentId' => $versionInfo->contentInfo->id]
2009
            );
2010
        }
2011
2012
        if (!in_array($languageCode, $versionInfo->languageCodes)) {
2013
            throw new InvalidArgumentException(