| Conditions | 1 |
| Paths | 1 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function generate($relation): bool |
||
| 17 | { |
||
| 18 | $source = $relation['source']; |
||
| 19 | $file = (new ReflectionClass($source))->getFileName(); |
||
| 20 | $lines = file($file , FILE_IGNORE_NEW_LINES); |
||
| 21 | $content = str_replace( |
||
| 22 | ['$class$', '$method$', '$type$', '$target$', '$keys$'], |
||
| 23 | [ |
||
| 24 | $relation['type'], |
||
| 25 | $relation['method']['name'], |
||
| 26 | lcfirst($relation['type']), |
||
| 27 | $relation['target'], |
||
| 28 | $relation['keys'] ?? '', |
||
| 29 | ], |
||
| 30 | File::get(__DIR__.'/../../resources/stubs/relation.stub') |
||
| 31 | ); |
||
| 32 | |||
| 33 | $lines[$this->endOfClass($file) - 1] = PHP_EOL . $content. '}'; |
||
| 34 | |||
| 35 | return file_put_contents($file , implode( "\n", $lines)); |
||
| 36 | } |
||
| 37 | |||
| 52 |