| Conditions | 1 |
| Paths | 1 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function execute($relation) |
||
| 17 | { |
||
| 18 | $source = $relation['source']; |
||
| 19 | $stub = __DIR__ . '/../../resources/stubs/relation.stub'; |
||
| 20 | $file = (new ReflectionClass($source))->getFileName(); |
||
| 21 | $lines = file($file, FILE_IGNORE_NEW_LINES); |
||
| 22 | $injectionLine = $this->endOfClass($file) - 1; |
||
| 23 | |||
| 24 | $lines[$injectionLine] = PHP_EOL . $this->generateMethod($relation, $stub) . '}'; |
||
| 25 | |||
| 26 | file_put_contents($file, implode("\n", $lines)); |
||
| 27 | |||
| 28 | return (object) [ |
||
| 29 | 'file' => $file, |
||
| 30 | 'line' => ($injectionLine + count(file($stub)) - 2), |
||
| 31 | ]; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param array $relation |
||
| 36 | * @param string $stub |
||
| 37 | * @return string|string[] |
||
| 74 |