JsonViolationExporter::export()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
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