AbstractCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace PhpVirusScanner\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Application;
9
10
class AbstractCommand extends Command
11
{
12
    /**
13
     * @var float
14
     */
15
    protected $startTime;
16
17
    /**
18
     * @var Application
19
     */
20
    protected $console;
21
22
    /**
23
     * @var InputInterface
24
     */
25
    protected $input;
26
27
    /**
28
     * @var OutputInterface
29
     */
30
    protected $output;
31
32
    /**
33
     *
34
     */
35
    public function __construct(Application $console)
36
    {
37
        $this->startTime = microtime(true);
38
39
        $this->console = $console;
40
41
        parent::__construct();
42
    }
43
44
    /**
45
     *
46
     */
47
    protected function printProfilerOutput()
48
    {
49
        $end = microtime(true);
50
        $totalSecs = $end - $this->startTime;
51
52
        $mins = floor($totalSecs / 60);
53
        $secs = $totalSecs - ($mins * 60);
54
55
        $this->output->write('Done in: ' . sprintf('%.3f', $totalSecs) . ' secs');
56
        $this->output->writeln(" ({$mins} mins " . sprintf('%.3f', $secs) . " secs)");
57
58
        $this->output->writeln('Max mem: ' . sprintf('%.3f', memory_get_peak_usage() / 1048576) . ' Mb');
59
    }
60
}
61