ConstantParserVisitor::visitConstants()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace gossi\codegen\parser\visitor;
5
6
use gossi\codegen\model\PhpConstant;
7
use gossi\codegen\parser\visitor\parts\MemberParserPart;
8
use gossi\codegen\parser\visitor\parts\ValueParserPart;
9
use PhpParser\Comment\Doc;
10
use PhpParser\Node\Const_;
11
use PhpParser\Node\Stmt\ClassConst;
12
13
class ConstantParserVisitor extends StructParserVisitor {
14
15
	use MemberParserPart;
16
	use ValueParserPart;
17
18 3
	public function visitConstants(ClassConst $node) {
19 3
		$doc = $node->getDocComment();
20 3
		foreach ($node->consts as $const) {
21 3
			$this->visitConstant($const, $doc);
22
		}
23 3
	}
24
25 3
	public function visitConstant(Const_ $node, Doc $doc = null) {
26 3
		$const = new PhpConstant($node->name->name);
27 3
		$this->parseValue($const, $node);
28 3
		$this->parseMemberDocblock($const, $doc);
29
30 3
		$this->struct->setConstant($const);
31 3
	}
32
}
33