Code Duplication    Length = 12-13 lines in 3 locations

src/AppBundle/Controller/NooliteController.php 3 locations

@@ 81-92 (lines=12) @@
78
                            break;
79
                        }
80
                    }
81
                } else {
82
                    // turning off
83
                    $changeSet = ['state'=>'off'];
84
                    /** @var Action $action */
85
                    foreach ($actions as $action) {
86
                        $args = json_decode($action->getArguments(), true);
87
                        if (isset($args['state']) && ($args['state'] == 'off')) {
88
                            $resultAction = $action;
89
                            break;
90
                        }
91
                    }
92
                }
93
            }
94
95
            if ($request->get('cmd') == 0) {
@@ 95-107 (lines=13) @@
92
                }
93
            }
94
95
            if ($request->get('cmd') == 0) {
96
                // turn off, only by pi
97
98
                $changeSet = ['state'=>'off'];
99
                /** @var Action $action */
100
                foreach ($actions as $action) {
101
                    $args = json_decode($action->getArguments(), true);
102
                    if (isset($args['state']) && ($args['state'] == 'off')) {
103
                        $resultAction = $action;
104
                        break;
105
                    }
106
                }
107
            }
108
109
            if ($request->get('cmd') == 6) {
110
                // turn off, only by pi
@@ 125-137 (lines=13) @@
122
                }
123
            }
124
125
            if ($request->get('cmd') == 2) {
126
                // turn on, only by pi
127
128
                $changeSet = ['state'=>'on'];
129
                /** @var Action $action */
130
                foreach ($actions as $action) {
131
                    $args = json_decode($action->getArguments(), true);
132
                    if (isset($args['state']) && ($args['state'] == 'on')) {
133
                        $resultAction = $action;
134
                        break;
135
                    }
136
                }
137
            }
138
139
            if (($changeSet['state'] == 'off') && !isset($changeSet['percent'])) {
140
                $changeSet['percent'] = 0;