Completed
Push — master ( 7195f8...c1e355 )
by Bill
10s
created

JsonResultsRenderer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 13 1
1
<?php declare(strict_types = 1);
2
3
4
namespace Churn\Renderers\Results;
5
6
use Churn\Results\ResultCollection;
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 ResultCollection $results Result Collection.
15
     * @return void
16
     */
17
    public function render(OutputInterface $output, ResultCollection $results)
18
    {
19
        $data = array_map(function (array $result) {
20
            return [
21
                'file' => $result[0],
22
                'commits' => $result[1],
23
                'complexity' => $result[2],
24
                'score' => $result[3],
25
            ];
26
        }, $results->toArray());
27
28
        $output->write(json_encode($data));
29
    }
30
}
31