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

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