Code Duplication    Length = 20-31 lines in 2 locations

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

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

src/POData/UriProcessor/UriProcessor.php 1 location

@@ 577-607 (lines=31) @@
574
     * @throws InvalidOperationException If this function invoked with non-navigation
575
     *                                   property instance.
576
     */
577
    private function _pushSegmentForNavigationProperty(ResourceProperty &$resourceProperty)
578
    {
579
        if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) {
580
            $this->assert(
581
                !empty($this->_segmentNames), 
582
                '!is_empty($this->_segmentNames'
583
            );
584
            $currentResourceSetWrapper = $this->_getCurrentResourceSetWrapper();
585
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
586
            $currentResourceSetWrapper = $this->service
587
                ->getProvidersWrapper()
588
                ->getResourceSetWrapperForNavigationProperty(
589
                    $currentResourceSetWrapper,
590
                    $currentResourceType,
591
                    $resourceProperty
592
                );
593
594
            $this->assert(
595
                !is_null($currentResourceSetWrapper), 
596
                '!null($currentResourceSetWrapper)'
597
            );
598
            return $this->_pushSegment(
599
                $resourceProperty->getName(), 
600
                $currentResourceSetWrapper
601
            );
602
        } else {
603
            throw new InvalidOperationException(
604
                'pushSegmentForNavigationProperty should not be called with non-entity type'
605
            );
606
        }
607
    }
608
609
    /**
610
     * Gets collection of expanded projection nodes under the current node.