Code Duplication    Length = 21-32 lines in 2 locations

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

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

src/POData/UriProcessor/UriProcessor.php 1 location

@@ 699-730 (lines=32) @@
696
     * @throws InvalidOperationException If this function invoked with non-navigation
697
     *                                   property instance
698
     */
699
    private function _pushSegmentForNavigationProperty(ResourceProperty & $resourceProperty)
700
    {
701
        if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) {
702
            $this->assert(
703
                !empty($this->_segmentNames),
704
                '!is_empty($this->_segmentNames'
705
            );
706
            $currentResourceSetWrapper = $this->_getCurrentResourceSetWrapper();
707
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
708
            $currentResourceSetWrapper = $this->getService()
709
                ->getProvidersWrapper()
710
                ->getResourceSetWrapperForNavigationProperty(
711
                    $currentResourceSetWrapper,
712
                    $currentResourceType,
713
                    $resourceProperty
714
                );
715
716
            $this->assert(
717
                !is_null($currentResourceSetWrapper),
718
                '!null($currentResourceSetWrapper)'
719
            );
720
721
            return $this->_pushSegment(
722
                $resourceProperty->getName(),
723
                $currentResourceSetWrapper
724
            );
725
        } else {
726
            throw new InvalidOperationException(
727
                'pushSegmentForNavigationProperty should not be called with non-entity type'
728
            );
729
        }
730
    }
731
732
    /**
733
     * Gets collection of expanded projection nodes under the current node.