Completed
Push — master ( a68eb8...eb5798 )
by Vitaly
03:48
created

ScreenshotReporter::report()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
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
use Symfony\Component\Console\Logger\ConsoleLogger;
8
9
10
/**
11
 * Screenshot reporter.
12
 *
13
 * @author Vitaly Egorov <[email protected]>
14
 */
15
class ScreenshotReporter extends Reporter implements ViolationReporterInterface
16
{
17
    /** Violations collection marker */
18
    const MARKER = 'screenshots';
19
20
    /** {@inheritdoc} */
21
    public function parseViolations() : array
22
    {
23
        /** @var array $violations Collection of violations grouped by files and lines */
24
        $violations = [];
25
26
        // Collection screenshots
27
        foreach (glob($this->path.'/*.jpg') as $image) {
28
            $violations[] = $image;
29
        }
30
31
        return $violations;
32
    }
33
34
    /** {@inheritdoc} */
35
    public function report(CloudReporter $bitbucket, ConsoleLogger $logger)
36
    {
37
        foreach ($this->parseViolations() as $screenshot) {
38
            $bitbucket->createGeneralComment('![Screent shot](' . $screenshot . ')');
39
            $logger->log(ConsoleLogger::INFO, 'Posting screenshot:' . $screenshot);
40
        }
41
    }
42
}
43