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

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