Code Duplication    Length = 24-31 lines in 2 locations

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

@@ 322-352 (lines=31) @@
319
     * 
320
     * @return ExpandedProjectionNode|null
321
     */
322
    protected function getCurrentExpandedProjectionNode()
323
    {
324
        $expandedProjectionNode = $this->request->getRootProjectionNode();
325
        if (is_null($expandedProjectionNode)) {
326
            return null;
327
        } else {
328
            $depth = count($this->_segmentNames);
329
            // $depth == 1 means serialization of root entry 
330
            //(the resource identified by resource path) is going on, 
331
            //so control won't get into the below for loop. 
332
            //we will directly return the root node, 
333
            //which is 'ExpandedProjectionNode'
334
            // for resource identified by resource path.
335
            if ($depth != 0) {
336
                for ($i = 1; $i < $depth; $i++) {
337
                    $expandedProjectionNode 
338
                        = $expandedProjectionNode->findNode($this->_segmentNames[$i]);
339
                        $this->assert(
340
                            !is_null($expandedProjectionNode), 
341
                            '!is_null($expandedProjectionNode)'
342
                        );
343
                        $this->assert(
344
                            $expandedProjectionNode instanceof ExpandedProjectionNode, 
345
                            '$expandedProjectionNode instanceof ExpandedProjectionNode'
346
                        );
347
                }
348
            } 
349
        }
350
351
        return $expandedProjectionNode;
352
    }
353
354
    /**
355
     * Check whether to expand a navigation property or not.

src/POData/UriProcessor/UriProcessor.php 1 location

@@ 636-659 (lines=24) @@
633
     *
634
     * @return ExpandedProjectionNode|null
635
     */
636
    private function _getCurrentExpandedProjectionNode()
637
    {
638
        $expandedProjectionNode 
639
            = $this->request->getRootProjectionNode();
640
        if (!is_null($expandedProjectionNode)) {
641
            $depth = count($this->_segmentNames);
642
            if ($depth != 0) {
643
                for ($i = 1; $i < $depth; $i++) {
644
                    $expandedProjectionNode
645
                        = $expandedProjectionNode->findNode($this->_segmentNames[$i]);
646
                        $this->assert(
647
                            !is_null($expandedProjectionNode),
648
                            '!is_null($expandedProjectionNode)'
649
                        );
650
                        $this->assert(
651
                            $expandedProjectionNode instanceof ExpandedProjectionNode,
652
                            '$expandedProjectionNode instanceof ExpandedProjectionNode'
653
                        );
654
                }
655
            }
656
        }
657
658
        return $expandedProjectionNode;
659
    }
660
661
    /**
662
     * Pushes information about the segment whose instance is going to be