Moisture   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 23
ccs 0
cts 14
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getData() 0 19 2
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