Completed
Pull Request — master (#4)
by Tibor
09:05 queued 50s
created

Console   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 4 1
A printLogs() 0 9 2
1
<?php
2
3
namespace Bex\Behat\StepTimeLoggerExtension\Service\OutputPrinter;
4
5
use Bex\Behat\StepTimeLoggerExtension\ServiceContainer\Config;
6
use Symfony\Component\Console\Helper\Table;
7
use Symfony\Component\Console\Output\ConsoleOutput;
8
9
class Console implements OutputPrinterInterface
10
{
11
    /**
12
     * @var ConsoleOutput
13
     */
14
    private $output;
15
    
16
    /**
17
     * @param ConsoleOutput $output
18
     */
19
    public function __construct(ConsoleOutput $output)
20
    {
21
        $this->output = $output;
22
    }
23
    
24
    /**
25
     * @param Config $config
26
     */
27
    public function configure(Config $config)
28
    {
29
        // no configuration required
30
    }
31
32
    /**
33
     * @param  array $calledCounts
34
     * @param  array $avgTimes
35
     *
36
     * @return void
37
     */
38
    public function printLogs(array $calledCounts, array $avgTimes)
39
    {
40
        $table = new Table($this->output);
41
        $table->setHeaders(['Average execution Time', 'Called count', 'Step name']);
42
        foreach ($avgTimes as $stepName => $time) {
43
            $table->addRow([$time, $calledCounts[$stepName], $stepName]);
44
        }
45
        $table->render();
46
    }
47
}