Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
28 | 9 | public function beforeTraverse(array $nodes) |
|
29 | { |
||
30 | // namespaces can be only top-level nodes, so we can scan them directly |
||
31 | 9 | foreach ($nodes as $topLevelNode) { |
|
32 | 9 | if ($topLevelNode instanceof Namespace_) { |
|
33 | // file has namespace in it, nothing to change, returning null |
||
34 | 9 | return null; |
|
35 | } |
||
36 | } |
||
37 | |||
38 | // if we don't have a namespaces at all, this is global namespace, wrap everything in it |
||
39 | 1 | $globalNamespaceNode = new Namespace_(new FullyQualified(''), $nodes); |
|
40 | |||
41 | 1 | return [$globalNamespaceNode]; |
|
42 | } |
||
43 | } |
||
44 |