Code Duplication    Length = 20-31 lines in 2 locations

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

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

src/POData/UriProcessor/UriProcessor.php 1 location

@@ 832-862 (lines=31) @@
829
     * @throws InvalidOperationException If this function invoked with non-navigation
830
     *                                   property instance.
831
     */
832
    private function _pushSegmentForNavigationProperty(ResourceProperty &$resourceProperty)
833
    {
834
        if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) {
835
            $this->assert(
836
                !empty($this->_segmentNames),
837
                '!is_empty($this->_segmentNames'
838
            );
839
            $currentResourceSetWrapper = $this->_getCurrentResourceSetWrapper();
840
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
841
            $currentResourceSetWrapper = $this->service
842
                ->getProvidersWrapper()
843
                ->getResourceSetWrapperForNavigationProperty(
844
                    $currentResourceSetWrapper,
845
                    $currentResourceType,
846
                    $resourceProperty
847
                );
848
849
            $this->assert(
850
                !is_null($currentResourceSetWrapper),
851
                '!null($currentResourceSetWrapper)'
852
            );
853
            return $this->_pushSegment(
854
                $resourceProperty->getName(),
855
                $currentResourceSetWrapper
856
            );
857
        } else {
858
            throw new InvalidOperationException(
859
                'pushSegmentForNavigationProperty should not be called with non-entity type'
860
            );
861
        }
862
    }
863
864
    /**
865
     * Gets collection of expanded projection nodes under the current node.