Code Duplication    Length = 20-20 lines in 3 locations

eZ/Publish/Core/Repository/LocationService.php 3 locations

@@ 132-151 (lines=20) @@
129
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
130
         */
131
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion();
132
        if ($contentReadCriterion === false) {
133
            throw new UnauthorizedException('content', 'read');
134
        } elseif ($contentReadCriterion !== true) {
135
            // Query if there are any content in subtree current user don't have access to
136
            $query = new Query(
137
                [
138
                    'limit' => 0,
139
                    'filter' => new CriterionLogicalAnd(
140
                        [
141
                            new CriterionSubtree($loadedSubtree->pathString),
142
                            new CriterionLogicalNot($contentReadCriterion),
143
                        ]
144
                    ),
145
                ]
146
            );
147
            $result = $this->repository->getSearchService()->findContent($query, [], false);
148
            if ($result->totalCount > 0) {
149
                throw new UnauthorizedException('content', 'read');
150
            }
151
        }
152
153
        $this->repository->beginTransaction();
154
        try {
@@ 679-698 (lines=20) @@
676
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
677
         */
678
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion();
679
        if ($contentReadCriterion === false) {
680
            throw new UnauthorizedException('content', 'read');
681
        } elseif ($contentReadCriterion !== true) {
682
            // Query if there are any content in subtree current user don't have access to
683
            $query = new Query(
684
                [
685
                    'limit' => 0,
686
                    'filter' => new CriterionLogicalAnd(
687
                        [
688
                            new CriterionSubtree($location->pathString),
689
                            new CriterionLogicalNot($contentReadCriterion),
690
                        ]
691
                    ),
692
                ]
693
            );
694
            $result = $this->repository->getSearchService()->findContent($query, [], false);
695
            if ($result->totalCount > 0) {
696
                throw new UnauthorizedException('content', 'read');
697
            }
698
        }
699
700
        if (strpos($newParentLocation->pathString, $location->pathString) === 0) {
701
            throw new InvalidArgumentException(
@@ 758-777 (lines=20) @@
755
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
756
         */
757
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion('content', 'remove');
758
        if ($contentReadCriterion === false) {
759
            throw new UnauthorizedException('content', 'remove');
760
        } elseif ($contentReadCriterion !== true) {
761
            // Query if there are any content in subtree current user don't have access to
762
            $query = new Query(
763
                [
764
                    'limit' => 0,
765
                    'filter' => new CriterionLogicalAnd(
766
                        [
767
                            new CriterionSubtree($location->pathString),
768
                            new CriterionLogicalNot($contentReadCriterion),
769
                        ]
770
                    ),
771
                ]
772
            );
773
            $result = $this->repository->getSearchService()->findContent($query, [], false);
774
            if ($result->totalCount > 0) {
775
                throw new UnauthorizedException('content', 'remove');
776
            }
777
        }
778
779
        $this->repository->beginTransaction();
780
        try {