Console::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 \Generator $avgTimes
34
     *
35
     * @return void
36
     */
37
    public function printLogs(\Generator $avgTimes)
38
    {
39
        $table = new Table($this->output);
40
        $table->setHeaders(['Average execution Time', 'Called count', 'Total Cost', 'Step name']);
41
        foreach ($avgTimes as $stepName => $info) {
42
            $table->addRow([$info['avg_execution_time'], $info['total_executions'], $info['total_cost'], $stepName]);
43
        }
44
        $table->render();
45
    }
46
}
47