| Total Complexity | 5 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | final class CodeAnalyseCommand extends Command |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * @var \Illuminate\Foundation\Application |
||
| 27 | */ |
||
| 28 | protected $laravel; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * {@inheritdoc} |
||
| 32 | */ |
||
| 33 | protected $signature = 'code:analyse {--level=1}'; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * {@inheritdoc} |
||
| 37 | */ |
||
| 38 | protected $description = 'Analyses source code'; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | */ |
||
| 43 | public function handle(): void |
||
| 44 | { |
||
| 45 | $level = is_string($this->option('level')) ? $this->option('level') : 'max'; |
||
|
|
|||
| 46 | |||
| 47 | $params = [ |
||
| 48 | static::phpstanBinary(), |
||
| 49 | 'analyse', |
||
| 50 | '--level='.$level, |
||
| 51 | '--autoload-file='.$this->laravel->basePath('vendor/autoload.php'), |
||
| 52 | '--configuration='.__DIR__.'/../../extension.neon', |
||
| 53 | $this->laravel['path'], |
||
| 54 | ]; |
||
| 55 | |||
| 56 | $process = new Process(implode(' ', $params), $this->laravel->basePath('vendor/bin')); |
||
| 57 | |||
| 58 | if (Process::isTtySupported()) { |
||
| 59 | $process->setTty(true); |
||
| 60 | } |
||
| 61 | |||
| 62 | $process->setTimeout(null); |
||
| 63 | |||
| 64 | $process->start(); |
||
| 65 | |||
| 66 | foreach ($process as $type => $data) { |
||
| 67 | $this->output->writeln($data); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | private static function phpstanBinary(): string |
||
| 77 | } |
||
| 78 | } |
||
| 79 |