Passed
Push — 4.x ( 17e0c5...e9b635 )
by Doug
07:44
created

RemoveExistingConstantsVisitor::leaveNode()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 3
nc 3
nop 1
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord\EPSG\Import;
10
11
use PhpParser\Node;
12
use PhpParser\Node\Stmt\ClassConst;
13
use PhpParser\NodeTraverser;
14
use PhpParser\NodeVisitorAbstract;
15
16
class RemoveExistingConstantsVisitor extends NodeVisitorAbstract
17
{
18
    public function leaveNode(Node $node)
19
    {
20
        if ($node instanceof ClassConst) {
21
            if (str_starts_with($node->consts[0]->name->name, 'EPSG')) {
22
                return NodeTraverser::REMOVE_NODE;
23
            }
24
        }
25
26
        return null;
27
    }
28
}
29