ParameterBuilder::build()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 9.6666
c 0
b 0
f 0
cc 4
nc 8
nop 1
crap 4
1
<?php
2
declare(strict_types=1);
3
4
namespace gossi\codegen\generator\builder;
5
6
use gossi\codegen\generator\builder\parts\TypeBuilderPart;
7
use gossi\codegen\generator\builder\parts\ValueBuilderPart;
8
use gossi\codegen\model\AbstractModel;
9
10
class ParameterBuilder extends AbstractBuilder {
11
12
	use ValueBuilderPart;
13
	use TypeBuilderPart;
14
15 11
	public function build(AbstractModel $model): void {
16 11
		$type = $this->getType($model, $this->config->getGenerateScalarTypeHints(), $this->config->getGenerateNullableTypes());
17 11
		if ($type !== null) {
18 4
			$this->writer->write($type . ' ');
19
		}
20
21 11
		if ($model->isPassedByReference()) {
22 2
			$this->writer->write('&');
23
		}
24
25 11
		$this->writer->write('$' . $model->getName());
26
27 11
		if ($model->hasValue()) {
28 3
			$this->writer->write(' = ');
29
30 3
			$this->writeValue($model);
31
		}
32 11
	}
33
34
}
35