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

@@ 806-834 (lines=29) @@
803
     *
804
     * @return null|RootProjectionNode|ExpandedProjectionNode
805
     */
806
    protected function getCurrentExpandedProjectionNode()
807
    {
808
        $expandedProjectionNode = $this->getRequest()->getRootProjectionNode();
809
        if (null === $expandedProjectionNode) {
810
            return null;
811
        } else {
812
            $segmentNames = $this->getStack()->getSegmentNames();
813
            $depth = count($segmentNames);
814
            // $depth == 1 means serialization of root entry
815
            //(the resource identified by resource path) is going on,
816
            //so control won't get into the below for loop.
817
            //we will directly return the root node,
818
            //which is 'ExpandedProjectionNode'
819
            // for resource identified by resource path.
820
            if (0 != $depth) {
821
                for ($i = 1; $i < $depth; ++$i) {
822
                    $expandedProjectionNode = $expandedProjectionNode->findNode($segmentNames[$i]);
823
                    assert(null !== $expandedProjectionNode, 'is_null($expandedProjectionNode)');
824
                    assert(
825
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
826
                        '$expandedProjectionNode not instanceof ExpandedProjectionNode'
827
                    );
828
                }
829
            }
830
        }
831
832
        return $expandedProjectionNode;
833
    }
834
835
    /**
836
     * Builds the string corresponding to query parameters for top level results
837
     * (result set identified by the resource path) to be put in next page link.