Code Duplication    Length = 20-26 lines in 2 locations

src/POData/UriProcessor/RequestExpander.php 1 location

@@ 197-222 (lines=26) @@
194
     *
195
     * @return bool true if a segment was pushed, false otherwise
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

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