Code Duplication    Length = 20-29 lines in 2 locations

src/POData/UriProcessor/RequestExpander.php 1 location

@@ 250-269 (lines=20) @@
247
     *
248
     * @return ExpandedProjectionNode|null
249
     */
250
    private function getCurrentExpandedProjectionNode()
251
    {
252
        $expandedProjectionNode = $this->getRequest()->getRootProjectionNode();
253
        if (!is_null($expandedProjectionNode)) {
254
            $names = $this->getStack()->getSegmentNames();
255
            $depth = count($names);
256
            if (0 != $depth) {
257
                for ($i = 1; $i < $depth; ++$i) {
258
                    $expandedProjectionNode = $expandedProjectionNode->findNode($names[$i]);
259
                    assert(!is_null($expandedProjectionNode), '!is_null($expandedProjectionNode)');
260
                    assert(
261
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
262
                        '$expandedProjectionNode instanceof ExpandedProjectionNode'
263
                    );
264
                }
265
            }
266
        }
267
268
        return $expandedProjectionNode;
269
    }
270
271
    /**
272
     * Pushes information about the segment whose instance is going to be

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

@@ 342-370 (lines=29) @@
339
     *
340
     * @return ExpandedProjectionNode|null
341
     */
342
    protected function getCurrentExpandedProjectionNode()
343
    {
344
        $expandedProjectionNode = $this->getRequest()->getRootProjectionNode();
345
        if (is_null($expandedProjectionNode)) {
346
            return null;
347
        } else {
348
            $segmentNames = $this->getStack()->getSegmentNames();
349
            $depth = count($segmentNames);
350
            // $depth == 1 means serialization of root entry
351
            //(the resource identified by resource path) is going on,
352
            //so control won't get into the below for loop.
353
            //we will directly return the root node,
354
            //which is 'ExpandedProjectionNode'
355
            // for resource identified by resource path.
356
            if ($depth != 0) {
357
                for ($i = 1; $i < $depth; ++$i) {
358
                    $expandedProjectionNode
359
                        = $expandedProjectionNode->findNode($segmentNames[$i]);
360
                    assert(!is_null($expandedProjectionNode), 'is_null($expandedProjectionNode)');
361
                    assert(
362
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
363
                        '$expandedProjectionNode not instanceof ExpandedProjectionNode'
364
                    );
365
                }
366
            }
367
        }
368
369
        return $expandedProjectionNode;
370
    }
371
372
    /**
373
     * Check whether to expand a navigation property or not.