Passed
Pull Request — master (#248)
by Fabien
02:47
created

JsonResultsRenderer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 8
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 12 1
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Result\Render;
4
5
use function array_map;
6
use function json_encode;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class JsonResultsRenderer implements ResultsRendererInterface
10
{
11
    /**
12
     * Renders the results.
13
     * @param OutputInterface $output  Output Interface.
14
     * @param array           $results The results.
15
     * @return void
16
     */
17
    public function render(OutputInterface $output, array $results): void
18
    {
19
        $data = array_map(static function (array $result): array {
20
            return [
21
                'file' => $result[0],
22
                'commits' => $result[1],
23
                'complexity' => $result[2],
24
                'score' => $result[3],
25
            ];
26
        }, $results);
27
28
        $output->write(json_encode($data));
29
    }
30
}
31