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

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