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

MeasureTemperatureCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 41.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 21
ccs 5
cts 12
cp 0.4167
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 10 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 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
        $exec = exec('/usr/bin/python '.__DIR__.'/../../../bin/bmp_i2c.py');
23
24
        $json = json_decode($exec, true);
25
        
26
        $varService = $this->getContainer()->get('vars');
27
        $varService->set('inside.temperature', $json['temp']);
28
        $varService->set('inside.pressure', round($json['press']));
29
    }
30
}
31