Completed
Push — master ( 5ac2a2...32410d )
by Kirill
06:44
created

MeasureSpeedCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 25
ccs 5
cts 15
cp 0.3333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 14 1
1
<?php
2
3
namespace AppBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class MeasureSpeedCommand extends ContainerAwareCommand
11
{
12 1
    protected function configure()
13
    {
14
        $this
15 1
            ->setName('home:measure-speed')
16 1
            ->setDescription('Measures internet speed.')
17 1
            ->setHelp("This command measures internet speed and writes it to local variable.");
18 1
    }
19
20
    protected function execute(InputInterface $input, OutputInterface $output)
21
    {
22
        $output->writeln('Measuring internet speed');
23
        $exec = exec('/usr/local/bin/speedtest-cli --server 6601 --json');
24
25
        $json = json_decode($exec, true);
26
27
        $output->writeln($exec);
28
29
        $varService = $this->getContainer()->get('vars');
30
        $varService->set('internet.download', round($json['download']));
31
        $varService->set('internet.upload', round($json['upload']));
32
        $varService->set('internet.ping', $json['ping']);
33
    }
34
}
35