| Total Complexity | 3 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class AddNewDataVisitor extends NodeVisitorAbstract |
||
| 18 | { |
||
| 19 | private array $data; |
||
| 20 | |||
| 21 | public function __construct(array $data) |
||
| 22 | { |
||
| 23 | $this->data = $data; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function enterNode(Node $node) |
||
| 27 | { |
||
| 28 | $factory = new BuilderFactory(); |
||
| 29 | if ($node instanceof ClassLike) { |
||
| 30 | $property = $factory->property('sridData')->makeProtected()->makeStatic()->setType('array')->setDefault($this->data)->setDocComment(''); |
||
| 31 | array_unshift($node->stmts, $property->getNode()); |
||
| 32 | |||
| 33 | return NodeTraverser::STOP_TRAVERSAL; |
||
| 34 | } |
||
| 35 | |||
| 36 | return null; |
||
| 37 | } |
||
| 39 |