Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
15 | 2 | public function fix(NodeSearch $nodeSearch): bool |
|
16 | { |
||
17 | 2 | $found = false; |
|
18 | /** @var Node\Expr\BinaryOp\Coalesce $node */ |
||
19 | 2 | foreach ($nodeSearch->eachType(Node\Expr\BinaryOp\Coalesce::class) as $node) { |
|
20 | 2 | $found = true; |
|
21 | 2 | $newNode = new Node\Expr\Ternary( |
|
22 | 2 | new Node\Expr\Isset_([$node->left]), |
|
23 | 2 | $node->left, |
|
24 | 2 | $node->right |
|
25 | ); |
||
26 | |||
27 | 2 | $nodeSearch->replaceNode($node, $newNode); |
|
28 | } |
||
29 | |||
30 | 2 | return $found; |
|
31 | } |
||
32 | } |
||
33 |