Code Duplication    Length = 20-29 lines in 2 locations

src/POData/UriProcessor/RequestExpander.php 1 location

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

src/POData/ObjectModel/ObjectModelSerializerBase.php 1 location

@@ 331-359 (lines=29) @@
328
     *
329
     * @return ExpandedProjectionNode|null
330
     */
331
    protected function getCurrentExpandedProjectionNode()
332
    {
333
        $expandedProjectionNode = $this->getRequest()->getRootProjectionNode();
334
        if (is_null($expandedProjectionNode)) {
335
            return null;
336
        } else {
337
            $segmentNames = $this->getStack()->getSegmentNames();
338
            $depth = count($segmentNames);
339
            // $depth == 1 means serialization of root entry
340
            //(the resource identified by resource path) is going on,
341
            //so control won't get into the below for loop.
342
            //we will directly return the root node,
343
            //which is 'ExpandedProjectionNode'
344
            // for resource identified by resource path.
345
            if ($depth != 0) {
346
                for ($i = 1; $i < $depth; ++$i) {
347
                    $expandedProjectionNode
348
                        = $expandedProjectionNode->findNode($segmentNames[$i]);
349
                    assert(!is_null($expandedProjectionNode), 'is_null($expandedProjectionNode)');
350
                    assert(
351
                        $expandedProjectionNode instanceof ExpandedProjectionNode,
352
                        '$expandedProjectionNode not instanceof ExpandedProjectionNode'
353
                    );
354
                }
355
            }
356
        }
357
358
        return $expandedProjectionNode;
359
    }
360
361
    /**
362
     * Check whether to expand a navigation property or not.