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

@@ 720-751 (lines=32) @@
717
     * @throws InvalidOperationException If this function invoked with non-navigation
718
     *                                   property instance
719
     */
720
    private function _pushSegmentForNavigationProperty(ResourceProperty &$resourceProperty)
721
    {
722
        if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) {
723
            $this->assert(
724
                !empty($this->_segmentNames),
725
                '!is_empty($this->_segmentNames'
726
            );
727
            $currentResourceSetWrapper = $this->_getCurrentResourceSetWrapper();
728
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
729
            $currentResourceSetWrapper = $this->getService()
730
                ->getProvidersWrapper()
731
                ->getResourceSetWrapperForNavigationProperty(
732
                    $currentResourceSetWrapper,
733
                    $currentResourceType,
734
                    $resourceProperty
735
                );
736
737
            $this->assert(
738
                !is_null($currentResourceSetWrapper),
739
                '!null($currentResourceSetWrapper)'
740
            );
741
742
            return $this->_pushSegment(
743
                $resourceProperty->getName(),
744
                $currentResourceSetWrapper
745
            );
746
        } else {
747
            throw new InvalidOperationException(
748
                'pushSegmentForNavigationProperty should not be called with non-entity type'
749
            );
750
        }
751
    }
752
753
    /**
754
     * Gets collection of expanded projection nodes under the current node.