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

@@ 760-783 (lines=24) @@
757
     *
758
     * @return ExpandedProjectionNode|null
759
     */
760
    private function _getCurrentExpandedProjectionNode()
761
    {
762
        $expandedProjectionNode
763
            = $this->request->getRootProjectionNode();
764
        if (!is_null($expandedProjectionNode)) {
765
            $depth = count($this->_segmentNames);
766
            if ($depth != 0) {
767
                for ($i = 1; $i < $depth; ++$i) {
768
                    $expandedProjectionNode
769
                        = $expandedProjectionNode->findNode($this->_segmentNames[$i]);
770
                    $this->assert(
771
                        !is_null($expandedProjectionNode),
772
                        '!is_null($expandedProjectionNode)'
773
                    );
774
                    $this->assert(
775
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
776
                        '$expandedProjectionNode instanceof ExpandedProjectionNode'
777
                    );
778
                }
779
            }
780
        }
781
782
        return $expandedProjectionNode;
783
    }
784
785
    /**
786
     * Pushes information about the segment whose instance is going to be