| Conditions | 4 |
| Paths | 8 |
| Total Lines | 30 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 39 | private static function sniffFile($file, $standards = '', $extensions = '') |
||
| 40 | { |
||
| 41 | $command = COMPOSER_VENDOR_DIR . '/bin/phpcs'; |
||
| 42 | |||
| 43 | if (!empty($standards)) { |
||
| 44 | $command .= " --standard=$standards"; |
||
| 45 | } |
||
| 46 | |||
| 47 | // @fixme: handle extensions properly (ex: the code is trying to sniff a .json file) |
||
| 48 | if (!empty($extensions)) { |
||
| 49 | $command .= " --extensions=$extensions"; |
||
| 50 | } |
||
| 51 | |||
| 52 | $command .= ' --report=json'; |
||
| 53 | |||
| 54 | $command .= " $file"; |
||
| 55 | |||
| 56 | $command = escapeshellcmd($command); |
||
| 57 | |||
| 58 | // Run phpcs and grab the output. |
||
| 59 | exec($command, $output); |
||
| 60 | |||
| 61 | if (is_null($output)) { |
||
| 62 | return null; |
||
| 63 | } |
||
| 64 | |||
| 65 | $result = json_decode(reset($output)); |
||
| 66 | |||
| 67 | return $result->files; |
||
| 68 | } |
||
| 69 | } |
||
| 70 |