ValueObjectGenerator::generate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 15
cp 0
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
namespace Mathielen\ImportEngineBundle\Generator;
4
5
use Sensio\Bundle\GeneratorBundle\Generator\Generator;
6
7
class ValueObjectGenerator extends Generator
8
{
9
    public function generate(array $fieldDefinitions = array(), $clsName, $path)
10
    {
11
        $fileName = str_replace('\\', '/', $clsName).'.php';
12
        $file = $path.'/'.$fileName;
13
14
        $clsToken = explode('\\', $clsName);
15
        $class = array_pop($clsToken);
16
        $namespace = implode('\\', $clsToken);
17
18
        $parameters = array(
19
            'namespace' => $namespace,
20
            'class' => $class,
21
            'field_definitions' => $fieldDefinitions,
22
        );
23
24
        $this->renderFile('ValueObject.php.twig', $file, $parameters);
25
26
        return $file;
27
    }
28
}
29