Code Duplication    Length = 38-39 lines in 2 locations

source/Snapshotter/AggregationHandler/Controllers/SnapshotsController.php 2 locations

@@ 229-267 (lines=39) @@
226
     * @param SnapshotSource $snapshotSource
227
     * @return array|\Psr\Http\Message\ResponseInterface
228
     */
229
    public function suppressIncidentAction(
230
        $id,
231
        IncidentSource $incidentSource,
232
        SnapshotSource $snapshotSource
233
    ) {
234
        /** @var SnapshotRecord $snapshot */
235
        $snapshot = $snapshotSource->findWithLastByPK($id);
236
        if (empty($snapshot)) {
237
            throw new NotFoundException;
238
        }
239
240
        /** @var IncidentRecord $incident */
241
        $incident = $incidentSource->findStoredBySnapshotByPK(
242
            $snapshot,
243
            $this->input->query('incident')
244
        );
245
        if (empty($incident)) {
246
            throw new NotFoundException;
247
        }
248
249
        $this->authorize('edit', compact('snapshot'));
250
251
        $incident->suppress();
252
        $incident->save();
253
254
        $uri = $this->vault
255
            ->uri('snapshots:view', ['id' => $snapshot->primaryKey()])
256
            ->withFragment('history');
257
258
        if ($this->input->isAjax()) {
259
            return [
260
                'status'  => 200,
261
                'message' => $this->say('Snapshot incident suppressed.'),
262
                'action'  => ['redirect' => $uri]
263
            ];
264
        } else {
265
            return $this->response->redirect($uri);
266
        }
267
    }
268
269
    /**
270
     * View snapshot incident.
@@ 346-383 (lines=38) @@
343
     * @param SnapshotSource $snapshotSource
344
     * @return array|\Psr\Http\Message\ResponseInterface
345
     */
346
    public function removeIncidentAction(
347
        $id,
348
        IncidentSource $incidentSource,
349
        SnapshotSource $snapshotSource
350
    ) {
351
        /** @var SnapshotRecord $snapshot */
352
        $snapshot = $snapshotSource->findWithLastByPK($id);
353
        if (empty($snapshot)) {
354
            throw new NotFoundException;
355
        }
356
357
        /** @var IncidentRecord $incident */
358
        $incident = $incidentSource->findBySnapshotByPK(
359
            $snapshot,
360
            $this->input->query('incident')
361
        );
362
        if (empty($incident)) {
363
            throw new NotFoundException;
364
        }
365
366
        $this->authorize('edit', compact('snapshot'));
367
368
        $incident->delete();
369
370
        $uri = $this->vault
371
            ->uri('snapshots:view', ['id' => $snapshot->primaryKey()])
372
            ->withFragment('history');
373
374
        if ($this->input->isAjax()) {
375
            return [
376
                'status'  => 200,
377
                'message' => $this->say('Snapshot incident deleted.'),
378
                'action'  => ['redirect' => $uri]
379
            ];
380
        } else {
381
            return $this->response->redirect($uri);
382
        }
383
    }
384
}