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

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