| Conditions | 1 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 5 | public function getCode(string $hook): string |
|
| 34 | { |
||
| 35 | 5 | return '#!/usr/bin/env php' . PHP_EOL . |
|
| 36 | 5 | '<?php' . PHP_EOL . |
|
| 37 | 5 | '$autoLoader = ' . $this->vendorPath . '/autoload.php\';' . PHP_EOL . PHP_EOL . |
|
| 38 | 5 | 'if (!file_exists($autoLoader)) {' . PHP_EOL . |
|
| 39 | 5 | ' fwrite(STDERR,' . PHP_EOL . |
|
| 40 | 5 | ' \'Composer autoload.php could not be found\' . PHP_EOL .' . PHP_EOL . |
|
| 41 | 5 | ' \'Please re-install the hook with:\' . PHP_EOL .' . PHP_EOL . |
|
| 42 | 5 | ' \'$ captainhook install --composer-vendor-path=...\' . PHP_EOL' . PHP_EOL . |
|
| 43 | 5 | ' );' . PHP_EOL . |
|
| 44 | 5 | ' exit(1);' . PHP_EOL . |
|
| 45 | 5 | '}' . PHP_EOL . |
|
| 46 | 5 | 'require $autoLoader;' . PHP_EOL . |
|
| 47 | 5 | '$config = realpath(' . $this->configPath . '\');' . PHP_EOL . |
|
| 48 | 5 | '$app = new CaptainHook\App\Console\Application\Hook();' . PHP_EOL . |
|
| 49 | 5 | '$app->setHook(\'' . $hook . '\');' . PHP_EOL . |
|
| 50 | 5 | '$app->setConfigFile($config);' . PHP_EOL . |
|
| 51 | 5 | '$app->run();' . PHP_EOL . PHP_EOL; |
|
| 52 | } |
||
| 53 | } |