| Total Complexity | 8 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class PhpMnd implements FileChecker |
||
| 7 | { |
||
| 8 | private $invalidLines = []; |
||
| 9 | |||
| 10 | private $file; |
||
| 11 | |||
| 12 | public function __construct($filename) |
||
| 13 | { |
||
| 14 | $this->file = fopen($filename, 'r'); |
||
| 15 | } |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @inheritdoc |
||
| 19 | */ |
||
| 20 | public function parseLines(): array |
||
| 21 | { |
||
| 22 | while (($line = fgets($this->file)) !== false) { |
||
|
|
|||
| 23 | $matches = []; |
||
| 24 | $pattern = "/^(?<filename>[^:]+):(?<lineNo>[0-9]+)\. (?<message>.+)/"; |
||
| 25 | if (preg_match($pattern, $line, $matches)) { |
||
| 26 | $this->invalidLines |
||
| 27 | [$matches['filename']] |
||
| 28 | [$matches['lineNo']][] = $matches['message']; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | return array_keys($this->invalidLines); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @inheritdoc |
||
| 37 | */ |
||
| 38 | public function getErrorsOnLine(string $file, int $lineNumber) |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * return as true to include files, phpmnd only shows files with errors |
||
| 50 | */ |
||
| 51 | public function handleNotFoundFile() |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritdoc} |
||
| 58 | */ |
||
| 59 | public static function getDescription(): string |
||
| 62 | } |
||
| 63 | } |
||
| 64 |