Code Duplication    Length = 20-26 lines in 2 locations

src/POData/UriProcessor/RequestExpander.php 1 location

@@ 197-222 (lines=26) @@
194
     * @throws InvalidOperationException If this function invoked with non-navigation
195
     *                                   property instance
196
     */
197
    private function pushSegmentForNavigationProperty(ResourceProperty &$resourceProperty)
198
    {
199
        if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) {
200
            assert(!empty($this->getStack()->getSegmentNames()), '!is_empty($this->getStack()->getSegmentNames())');
201
            $currentResourceSetWrapper = $this->getCurrentResourceSetWrapper();
202
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
203
            $currentResourceSetWrapper = $this->getService()
204
                ->getProvidersWrapper()
205
                ->getResourceSetWrapperForNavigationProperty(
206
                    $currentResourceSetWrapper,
207
                    $currentResourceType,
208
                    $resourceProperty
209
                );
210
211
            assert(!is_null($currentResourceSetWrapper), '!null($currentResourceSetWrapper)');
212
213
            return $this->pushSegment(
214
                $resourceProperty->getName(),
215
                $currentResourceSetWrapper
216
            );
217
        } else {
218
            throw new InvalidOperationException(
219
                'pushSegmentForNavigationProperty should not be called with non-entity type'
220
            );
221
        }
222
    }
223
224
    /**
225
     * Gets collection of expanded projection nodes under the current node.

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

@@ 284-303 (lines=20) @@
281
     * @throws InvalidOperationException If this function invoked with non-navigation
282
     *                                   property instance
283
     */
284
    protected function pushSegmentForNavigationProperty(ResourceProperty & $resourceProperty)
285
    {
286
        if (ResourceTypeKind::ENTITY == $resourceProperty->getTypeKind()) {
287
            assert(!empty($this->getStack()->getSegmentNames()), 'Segment names should not be empty');
288
            $currentResourceSetWrapper = $this->getCurrentResourceSetWrapper();
289
            $currentResourceType = $currentResourceSetWrapper->getResourceType();
290
            $currentResourceSetWrapper = $this->getService()
291
                ->getProvidersWrapper()
292
                ->getResourceSetWrapperForNavigationProperty(
293
                    $currentResourceSetWrapper,
294
                    $currentResourceType,
295
                    $resourceProperty
296
                );
297
298
            assert(!is_null($currentResourceSetWrapper), 'is_null($currentResourceSetWrapper)');
299
300
            return $this->_pushSegment($resourceProperty->getName(), $currentResourceSetWrapper);
301
        }
302
        throw new InvalidOperationException('pushSegmentForNavigationProperty should not be called with non-entity type');
303
    }
304
305
    /**
306
     * Gets collection of projection nodes under the current node.