Moisture::getData()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 14
cp 0
rs 9.4285
cc 2
eloc 11
nc 2
nop 1
crap 6
1
<?php
2
3
namespace AppBundle\Action\Executor;
4
5
use AppBundle\Entity\Action;
6
use AppBundle\Entity\VarHook;
7
use AppBundle\Entity\Variable;
8
9
class Moisture extends BaseExecutor implements ExecutorInterface
10
{
11
12
    public function getData(Action $action)
0 ignored issues
show
Unused Code introduced by
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
13
    {
14
        $varService = $this->getContainer()->get('vars');
15
16
        $fp = file_get_contents("http://192.168.0.221/data.json");
17
18
        if (!$fp) {
19
            return 'Couldn\'t connect to sensor';
20
        }
21
22
        $this->getContainer()->get('logger')->addInfo('Got sensor data: '.$fp);
23
        $fp = json_decode($fp, true);
24
25
        $varService->set('outside.temperature', $fp['data']['temperature']);
26
        $varService->set('moisture.raw', $fp['data']['rowmoisture']);
27
        $varService->set('moisture.combined', $fp['data']['moisture']);
28
29
        return 'Info recorded successfully';
30
    }
31
}
32