Code Duplication    Length = 20-31 lines in 2 locations

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

@@ 275-294 (lines=20) @@
272
     * @throws InvalidOperationException If this function invoked with non-navigation
273
     *                                   property instance.
274
     */
275
    protected function pushSegmentForNavigationProperty(ResourceProperty &$resourceProperty)
276
    {
277
        if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) {
278
            $this->assert(!empty($this->_segmentNames), '!is_empty($this->_segmentNames');
279
            $currentResourceSetWrapper = $this->getCurrentResourceSetWrapper();
280
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
281
            $currentResourceSetWrapper = $this->service
282
                ->getProvidersWrapper()
283
                ->getResourceSetWrapperForNavigationProperty(
284
                    $currentResourceSetWrapper, 
285
                    $currentResourceType, 
286
                    $resourceProperty
287
                );
288
289
            $this->assert(!is_null($currentResourceSetWrapper), '!null($currentResourceSetWrapper)');
290
            return $this->_pushSegment($resourceProperty->getName(), $currentResourceSetWrapper);
291
        } else {
292
            throw new InvalidOperationException('pushSegmentForNavigationProperty should not be called with non-entity type');
293
        }
294
    }
295
296
    /**
297
     * Gets collection of projection nodes under the current node.

src/POData/UriProcessor/UriProcessor.php 1 location

@@ 672-702 (lines=31) @@
669
     * @throws InvalidOperationException If this function invoked with non-navigation
670
     *                                   property instance.
671
     */
672
    private function _pushSegmentForNavigationProperty(ResourceProperty &$resourceProperty)
673
    {
674
        if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) {
675
            $this->assert(
676
                !empty($this->_segmentNames),
677
                '!is_empty($this->_segmentNames'
678
            );
679
            $currentResourceSetWrapper = $this->_getCurrentResourceSetWrapper();
680
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
681
            $currentResourceSetWrapper = $this->service
682
                ->getProvidersWrapper()
683
                ->getResourceSetWrapperForNavigationProperty(
684
                    $currentResourceSetWrapper,
685
                    $currentResourceType,
686
                    $resourceProperty
687
                );
688
689
            $this->assert(
690
                !is_null($currentResourceSetWrapper),
691
                '!null($currentResourceSetWrapper)'
692
            );
693
            return $this->_pushSegment(
694
                $resourceProperty->getName(),
695
                $currentResourceSetWrapper
696
            );
697
        } else {
698
            throw new InvalidOperationException(
699
                'pushSegmentForNavigationProperty should not be called with non-entity type'
700
            );
701
        }
702
    }
703
704
    /**
705
     * Gets collection of expanded projection nodes under the current node.