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

@@ 821-849 (lines=29) @@
818
     *
819
     * @return null|RootProjectionNode|ExpandedProjectionNode
820
     */
821
    protected function getCurrentExpandedProjectionNode()
822
    {
823
        $expandedProjectionNode = $this->getRequest()->getRootProjectionNode();
824
        if (null === $expandedProjectionNode) {
825
            return null;
826
        } else {
827
            $segmentNames = $this->getStack()->getSegmentNames();
828
            $depth = count($segmentNames);
829
            // $depth == 1 means serialization of root entry
830
            //(the resource identified by resource path) is going on,
831
            //so control won't get into the below for loop.
832
            //we will directly return the root node,
833
            //which is 'ExpandedProjectionNode'
834
            // for resource identified by resource path.
835
            if (0 != $depth) {
836
                for ($i = 1; $i < $depth; ++$i) {
837
                    $expandedProjectionNode = $expandedProjectionNode->findNode($segmentNames[$i]);
838
                    assert(null !== $expandedProjectionNode, 'is_null($expandedProjectionNode)');
839
                    assert(
840
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
841
                        '$expandedProjectionNode not instanceof ExpandedProjectionNode'
842
                    );
843
                }
844
            }
845
        }
846
847
        return $expandedProjectionNode;
848
    }
849
850
    /**
851
     * Builds the string corresponding to query parameters for top level results
852
     * (result set identified by the resource path) to be put in next page link.