Completed
Push — master ( 6ddf59...027c5f )
by Vitaly
06:52 queued 04:29
created

ScreenshotReporter::parseViolations()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 9

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 0
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 22.09.16 at 15:26
5
 */
6
namespace samsonframework\bitbucket;
7
8
/**
9
 * Screenshot reporter.
10
 *
11
 * @author Vitaly Egorov <[email protected]>
12
 */
13
class ScreenshotReporter extends Reporter implements ViolationReporterInterface
14
{
15
    /** {@inheritdoc} */
16 View Code Duplication
    public function parseViolations() : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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)), '/')];
0 ignored issues
show
Bug introduced by
The property basePath does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
            foreach ($file->violation as $violation) {
29
                $pointer[(string)$violation[self::LINENUMBER]][] = trim((string)$violation);
30
            }
31
        }
32
33
        return $violations;
34
    }
35
}
36