Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | public function addLineToFileIfItDoesNotExist(string $fileFromRoot, string $line): FileFixes |
||
12 | { |
||
13 | $file = $this->mu()->getWebRootDirLocation() . '/' . $fileFromRoot; |
||
14 | if (! file_exists($file)) { |
||
15 | user_error('Can not find ' . $file); |
||
16 | } |
||
17 | $line = addslashes($line); |
||
18 | $this->mu()->execMe( |
||
19 | dirname($fileFromRoot), |
||
20 | 'grep -qxF \'' . $line . '\' ' . $file . ' || echo \'' . $line . '\' >>' . $file, |
||
21 | 'Add line ' . $line . ' to ' . $file, |
||
22 | false |
||
23 | ); |
||
24 | |||
25 | return $this; |
||
26 | } |
||
28 |