Code Duplication    Length = 20-29 lines in 2 locations

src/POData/UriProcessor/RequestExpander.php 1 location

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

src/POData/ObjectModel/CynicSerialiser.php 1 location

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