Code Duplication    Length = 20-29 lines in 2 locations

src/POData/UriProcessor/RequestExpander.php 1 location

@@ 256-275 (lines=20) @@
253
     *
254
     * @return ExpandedProjectionNode|null
255
     */
256
    private function getCurrentExpandedProjectionNode()
257
    {
258
        $expandedProjectionNode = $this->getRequest()->getRootProjectionNode();
259
        if (null !== $expandedProjectionNode) {
260
            $names = $this->getStack()->getSegmentNames();
261
            $depth = count($names);
262
            if (0 != $depth) {
263
                for ($i = 1; $i < $depth; ++$i) {
264
                    $expandedProjectionNode = $expandedProjectionNode->findNode($names[$i]);
265
                    assert(null !== $expandedProjectionNode, '!is_null($expandedProjectionNode)');
266
                    assert(
267
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
268
                        '$expandedProjectionNode instanceof ExpandedProjectionNode'
269
                    );
270
                }
271
            }
272
        }
273
274
        return $expandedProjectionNode;
275
    }
276
277
    /**
278
     * Pushes information about the segment whose instance is going to be

src/POData/ObjectModel/CynicSerialiser.php 1 location

@@ 847-875 (lines=29) @@
844
     *
845
     * @return null|RootProjectionNode|ExpandedProjectionNode
846
     */
847
    protected function getCurrentExpandedProjectionNode()
848
    {
849
        $expandedProjectionNode = $this->getRequest()->getRootProjectionNode();
850
        if (null === $expandedProjectionNode) {
851
            return null;
852
        } else {
853
            $segmentNames = $this->getStack()->getSegmentNames();
854
            $depth = count($segmentNames);
855
            // $depth == 1 means serialization of root entry
856
            //(the resource identified by resource path) is going on,
857
            //so control won't get into the below for loop.
858
            //we will directly return the root node,
859
            //which is 'ExpandedProjectionNode'
860
            // for resource identified by resource path.
861
            if (0 != $depth) {
862
                for ($i = 1; $i < $depth; ++$i) {
863
                    $expandedProjectionNode = $expandedProjectionNode->findNode($segmentNames[$i]);
864
                    assert(null !== $expandedProjectionNode, 'is_null($expandedProjectionNode)');
865
                    assert(
866
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
867
                        '$expandedProjectionNode not instanceof ExpandedProjectionNode'
868
                    );
869
                }
870
            }
871
        }
872
873
        return $expandedProjectionNode;
874
    }
875
876
    /**
877
     * Builds the string corresponding to query parameters for top level results
878
     * (result set identified by the resource path) to be put in next page link.