| Conditions | 6 | 
| Paths | 6 | 
| Total Lines | 27 | 
| Code Lines | 20 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 0 | 
| CRAP Score | 42 | 
| Changes | 0 | ||
| 1 | <?php | ||
| 26 | public function write(AbstractGeneratorCommand $command, array $files, array $answers, array &$results): bool | ||
| 27 |     { | ||
| 28 | $results = ['Generating code using template "' . $command->getTemplate() . '"...']; | ||
| 29 | $hasError = false; | ||
| 30 |         foreach ($files as $file) { | ||
| 31 | $relativePath = $file->getRelativePath(); | ||
| 32 |             if (!empty($answers[$file->getId()]) && $file->getOperation() !== CodeFile::OP_SKIP) { | ||
| 33 |                 try { | ||
| 34 | $file->save(); | ||
| 35 | $results[] = $file->getOperation() === CodeFile::OP_CREATE | ||
| 36 | ? " generated $relativePath" | ||
| 37 | : " overwrote $relativePath"; | ||
| 38 |                 } catch (Exception $e) { | ||
| 39 | $hasError = true; | ||
| 40 | $results[] = sprintf( | ||
| 41 | " generating %s\n - <span class=\"error\">%s</span>", | ||
| 42 | $relativePath, | ||
| 43 | $e->getMessage() | ||
| 44 | ); | ||
| 45 | } | ||
| 46 |             } else { | ||
| 47 | $results[] = " skipped $relativePath"; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | $results[] = 'done!'; | ||
| 51 | |||
| 52 | return !$hasError; | ||
| 53 | } | ||
| 55 |