JsonResultsRenderer::render()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 15
rs 9.9666
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Churn\Result\Render;
6
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * @internal
11
 */
12
final class JsonResultsRenderer implements ResultsRendererInterface
13
{
14
    /**
15
     * Renders the results.
16
     *
17
     * @param OutputInterface $output Output Interface.
18
     * @param array<array<float|integer|string>> $results The results.
19
     */
20
    #[\Override]
21
    public function render(OutputInterface $output, array $results): void
22
    {
23
        $data = [];
24
25
        foreach ($results as $result) {
26
            $data[] = [
27
                'commits' => $result[1],
28
                'complexity' => $result[2],
29
                'file' => $result[0],
30
                'score' => $result[3],
31
            ];
32
        }
33
34
        $output->write((string) \json_encode($data));
35
    }
36
}
37