Conditions | 5 |
Paths | 8 |
Total Lines | 27 |
Code Lines | 10 |
Lines | 27 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
22 | View Code Duplication | public function write() |
|
|
|||
23 | { |
||
24 | // Create module cache folder if not exists |
||
25 | if (!file_exists($this->path)) { |
||
26 | @mkdir($path, 0777, true); |
||
27 | } |
||
28 | |||
29 | foreach ($this->analyzers as $analyzerClass => $analyzer) { |
||
30 | // Analyze database structure and get entities metadata |
||
31 | foreach ($analyzer->analyze() as $metadata) { |
||
32 | // Iterate all generators for analyzer |
||
33 | foreach ($this->generators[$analyzerClass] as $generator) { |
||
34 | /** @var Generic $generator Create class generator */ |
||
35 | $generator = new $generator($this->codeGenerator->defNamespace($this->namespace), $metadata); |
||
36 | |||
37 | // Create entity generated class names |
||
38 | $file = $this->path . $generator->className . '.php'; |
||
39 | |||
40 | // Create entity query class files |
||
41 | file_put_contents($file, '<?php' . $generator->generate()); |
||
42 | |||
43 | // Require files |
||
44 | require($file); |
||
45 | } |
||
46 | } |
||
47 | } |
||
48 | } |
||
49 | } |
||
51 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.