Passed
Pull Request — 0.3 (#20)
by jean
03:19
created

StatDumpCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: darkilliant
5
 * Date: 6/24/18
6
 * Time: 11:32 AM.
7
 */
8
9
namespace Darkilliant\ProcessBundle\Command;
10
11
use Darkilliant\ProcessBundle\StatDumper\StatCliDumper;
12
use Darkilliant\ProcessBundle\StatDumper\StatsCalculator;
13
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Input\InputOption;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\Console\Style\SymfonyStyle;
18
19
/**
20
 * @internal
21
 * Class StatDumpCommand
22
 *
23
 * @codeCoverageIgnore
24
 */
25
class StatDumpCommand extends ContainerAwareCommand
26
{
27
    protected function configure()
28
    {
29
        $this->setName('process:stats');
30
        $this->addOption('zoom', null, InputOption::VALUE_NONE, 'zoom', null);
31
    }
32
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $outputHelper = new SymfonyStyle($input, $output);
36
37
        $data = json_decode(file_get_contents('stat.json'), true);
38
39
        $statCalculator = new StatsCalculator();
40
41
        $this->getContainer()->get(StatCliDumper::class)->dump(
42
            $statCalculator->calcul($data)['stats'] ?? [],
43
            $outputHelper
44
        );
45
    }
46
}
47