Conditions | 4 |
Paths | 4 |
Total Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | public static function check(array $files = [], array $parameters = null) |
||
27 | { |
||
28 | $errors = []; |
||
29 | foreach ($files as $file) { |
||
30 | if (false === self::exist($file, $parameters['phpmd_path'], 'php')) { |
||
31 | continue; |
||
32 | } |
||
33 | |||
34 | $process = new Process( |
||
35 | 'vendor/phpmd/phpmd/src/bin/phpmd ' . $file . ' text ' . implode(',', $parameters['phpmd_rules']) |
||
36 | ); |
||
37 | $process->setWorkingDirectory($parameters['root_directory']); |
||
38 | $process->run(); |
||
39 | |||
40 | if (!$process->isSuccessful()) { |
||
41 | $errors[] = new Error( |
||
42 | $file, |
||
43 | sprintf('<error>%s</error>', trim($process->getErrorOutput())), |
||
44 | sprintf('<error>%s</error>', trim($process->getOutput())) |
||
45 | ); |
||
46 | } |
||
47 | } |
||
48 | |||
49 | return $errors; |
||
50 | } |
||
51 | } |
||
52 |