JsonViolationExporter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A export() 0 6 1
A __construct() 0 3 1
1
<?php
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
7
namespace Mediact\DependencyGuard\Composer\Command\Exporter;
8
9
use Mediact\DependencyGuard\Exporter\ViolationExporterInterface;
10
use Mediact\DependencyGuard\Violation\ViolationIteratorInterface;
11
use Symfony\Component\Console\Style\SymfonyStyle;
12
13
class JsonViolationExporter implements ViolationExporterInterface
14
{
15
    /** @var SymfonyStyle */
16
    private $prompt;
17
18
    /**
19
     * Constructor.
20
     *
21
     * @param SymfonyStyle $prompt
22
     */
23 1
    public function __construct(SymfonyStyle $prompt)
24
    {
25 1
        $this->prompt = $prompt;
26 1
    }
27
28
    /**
29
     * Export the given violations.
30
     *
31
     * @param ViolationIteratorInterface $violations
32
     *
33
     * @return void
34
     */
35 1
    public function export(ViolationIteratorInterface $violations): void
36
    {
37 1
        $this->prompt->writeln(
38 1
            json_encode(
39 1
                $violations,
40 1
                JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
41
            )
42
        );
43 1
    }
44
}
45