Code Duplication    Length = 15-15 lines in 2 locations

src/Plugin/Temporal/Aggregator.php 2 locations

@@ 215-229 (lines=15) @@
212
213
            // merge states
214
            $clean = false;
215
            while (!$clean) {
216
                $clean = true;
217
                foreach ($states as $i => $state) {
218
                    if (array_key_exists($i+1, $states)) {
219
                        $next = $states[$i+1];
220
                        if (json_encode($state->data) == json_encode($next->data)) {
221
                            $states[$i]->end = $next->end;
222
                            unset($states[$i+1]);
223
                            $states = array_values($states);
224
                            $clean = false;
225
                            break;
226
                        }
227
                    }
228
                }
229
            }
230
231
            foreach ($states as $state) {
232
                $this->temporal->getMapper()->create('_temporal_link_aggregate', $state);
@@ 313-327 (lines=15) @@
310
311
        // merge states
312
        $clean = false;
313
        while (!$clean) {
314
            $clean = true;
315
            foreach ($states as $i => $state) {
316
                if (array_key_exists($i+1, $states)) {
317
                    $next = $states[$i+1];
318
                    if (json_encode($state->data) == json_encode($next->data)) {
319
                        $state->end = $next->end;
320
                        unset($states[$i+1]);
321
                        $states = array_values($states);
322
                        $clean = false;
323
                        break;
324
                    }
325
                }
326
            }
327
        }
328
329
        return $states;
330
    }