| @@ 38-55 (lines=18) @@ | ||
| 35 | } |
|
| 36 | ||
| 37 | /** {@inheritdoc} */ |
|
| 38 | public function parseViolations() : array |
|
| 39 | { |
|
| 40 | // Read XML and convert to array |
|
| 41 | $xmlData = simplexml_load_string(file_get_contents($this->path)); |
|
| 42 | ||
| 43 | /** @var array $violations Collection of violations grouped by files and lines */ |
|
| 44 | $violations = []; |
|
| 45 | ||
| 46 | foreach ($xmlData->file as $file) { |
|
| 47 | $filePath = (string)$file[self::FILEPATH]; |
|
| 48 | $pointer = &$violations[ltrim(substr($filePath, strpos($filePath, $this->basePath)), '/')]; |
|
| 49 | foreach ($file->violation as $violation) { |
|
| 50 | $pointer[(string)$violation[self::LINENUMBER]][] = trim((string)$violation); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | return $violations; |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| @@ 16-34 (lines=19) @@ | ||
| 13 | class ScreenshotReporter extends Reporter implements ViolationReporterInterface |
|
| 14 | { |
|
| 15 | /** {@inheritdoc} */ |
|
| 16 | public function parseViolations() : array |
|
| 17 | { |
|
| 18 | ||
| 19 | // Read XML and convert to array |
|
| 20 | $xmlData = simplexml_load_string(file_get_contents($this->path)); |
|
| 21 | ||
| 22 | /** @var array $violations Collection of violations grouped by files and lines */ |
|
| 23 | $violations = []; |
|
| 24 | ||
| 25 | foreach ($xmlData->file as $file) { |
|
| 26 | $filePath = (string)$file[self::FILEPATH]; |
|
| 27 | $pointer = &$violations[ltrim(substr($filePath, strpos($filePath, $this->basePath)), '/')]; |
|
| 28 | foreach ($file->violation as $violation) { |
|
| 29 | $pointer[(string)$violation[self::LINENUMBER]][] = trim((string)$violation); |
|
| 30 | } |
|
| 31 | } |
|
| 32 | ||
| 33 | return $violations; |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||