| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public static function addPhpCsToPreCommitHook() |
||
| 15 | { |
||
| 16 | $originFile = getcwd() . '/.git/hooks/pre-commit'; |
||
| 17 | $templateContent = file_get_contents(__DIR__ . '/templates/git/hooks/pre-commit-phpcs'); |
||
| 18 | if (file_exists($originFile)) { |
||
| 19 | $originContent = file_get_contents($originFile); |
||
| 20 | if (strpos($originContent, '# run phpcs') === FALSE) { |
||
| 21 | $newContent = $originContent . PHP_EOL . PHP_EOL . $templateContent; |
||
| 22 | file_put_contents($originFile, $newContent); |
||
| 23 | } |
||
| 24 | |||
| 25 | } else { |
||
| 26 | file_put_contents($originFile, $templateContent); |
||
| 27 | } |
||
| 28 | chmod($originFile, 0755); |
||
| 29 | } |
||
| 30 | |||
| 32 |