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

Console::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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
}