Completed
Pull Request — master (#169)
by Bill
01:30
created

ConsoleResultsRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 11 1
A getHeader() 0 8 1
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Renderers\Results;
4
5
use Churn\Results\ResultCollection;
6
use Symfony\Component\Console\Helper\Table;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class ConsoleResultsRenderer 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
        $output->write($this->getHeader());
20
21
        $table = new Table($output);
22
        $table->setHeaders(['File', 'Times Changed', 'Complexity', 'Score']);
23
        $table->addRows($results->toArray());
24
        $table->render();
25
26
        $output->write("\n");
27
    }
28
29
    /**
30
     * Get the header.
31
     * @return string
32
     */
33
    private function getHeader(): string
34
    {
35
        return "\n
36
    ___  _   _  __  __  ____  _  _     ____  _   _  ____
37
   / __)( )_( )(  )(  )(  _ \( \( )___(  _ \( )_( )(  _ \
38
  ( (__  ) _ (  )(__)(  )   / )  ((___))___/ ) _ (  )___/
39
   \___)(_) (_)(______)(_)\_)(_)\_)   (__)  (_) (_)(__)      https://github.com/bmitch/churn-php\n\n";
40
    }
41
}
42