Code Duplication    Length = 24-31 lines in 2 locations

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

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

src/POData/UriProcessor/UriProcessor.php 1 location

@@ 779-802 (lines=24) @@
776
     *
777
     * @return ExpandedProjectionNode|null
778
     */
779
    private function _getCurrentExpandedProjectionNode()
780
    {
781
        $expandedProjectionNode
782
            = $this->request->getRootProjectionNode();
783
        if (!is_null($expandedProjectionNode)) {
784
            $depth = count($this->_segmentNames);
785
            if ($depth != 0) {
786
                for ($i = 1; $i < $depth; ++$i) {
787
                    $expandedProjectionNode
788
                        = $expandedProjectionNode->findNode($this->_segmentNames[$i]);
789
                    $this->assert(
790
                        !is_null($expandedProjectionNode),
791
                        '!is_null($expandedProjectionNode)'
792
                    );
793
                    $this->assert(
794
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
795
                        '$expandedProjectionNode instanceof ExpandedProjectionNode'
796
                    );
797
                }
798
            }
799
        }
800
801
        return $expandedProjectionNode;
802
    }
803
804
    /**
805
     * Pushes information about the segment whose instance is going to be