Code Duplication    Length = 20-31 lines in 2 locations

src/POData/UriProcessor/UriProcessor.php 1 location

@@ 702-732 (lines=31) @@
699
     * @throws InvalidOperationException If this function invoked with non-navigation
700
     *                                   property instance.
701
     */
702
    private function _pushSegmentForNavigationProperty(ResourceProperty &$resourceProperty)
703
    {
704
        if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) {
705
            $this->assert(
706
                !empty($this->_segmentNames),
707
                '!is_empty($this->_segmentNames'
708
            );
709
            $currentResourceSetWrapper = $this->_getCurrentResourceSetWrapper();
710
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
711
            $currentResourceSetWrapper = $this->service
712
                ->getProvidersWrapper()
713
                ->getResourceSetWrapperForNavigationProperty(
714
                    $currentResourceSetWrapper,
715
                    $currentResourceType,
716
                    $resourceProperty
717
                );
718
719
            $this->assert(
720
                !is_null($currentResourceSetWrapper),
721
                '!null($currentResourceSetWrapper)'
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.

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

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