Completed
Pull Request — master (#8)
by Kirill
26:11
created

MeasureTemperatureCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 2
crap 2
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 MeasureTemperatureCommand extends ContainerAwareCommand
11
{
12 1
    protected function configure()
13
    {
14
        $this
15 1
            ->setName('home:measure-temp')
16 1
            ->setDescription('Measures temperature and pressure.')
17 1
            ->setHelp("This command measures temperature and pressure 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/bin/python '.__DIR__.'/../../../bin/bmp_i2c.py');
24
25
        $json = json_decode($exec, true);
26
27
        $output->writeln($exec);
28
29
        $varService = $this->getContainer()->get('vars');
30
        $varService->set('inside.temperature', $json['temp']);
31
        $varService->set('inside.pressure', round($json['press']));
32
    }
33
}
34