Code Duplication    Length = 25-27 lines in 2 locations

source/Snapshotter/AggregationHandler/Controllers/SnapshotsController.php 1 location

@@ 175-201 (lines=27) @@
172
     * @param ServerRequestInterface $request
173
     * @return array|\Psr\Http\Message\ResponseInterface
174
     */
175
    public function removeAction(
176
        $id,
177
        SnapshotService $service,
178
        ServerRequestInterface $request
179
    ) {
180
        /** @var SnapshotRecord $snapshot */
181
        $snapshot = $service->getSource()->findWithLastByPK($id);
182
        if (empty($snapshot)) {
183
            throw new NotFoundException;
184
        }
185
186
        $this->authorize('remove', compact('snapshot'));
187
188
        $service->delete($snapshot);
189
190
        $uri = $this->removeBackURI($request);
191
192
        if ($this->input->isAjax()) {
193
            return [
194
                'status'  => 200,
195
                'message' => $this->say('Snapshot deleted.'),
196
                'action'  => ['redirect' => $uri]
197
            ];
198
        } else {
199
            return $this->response->redirect($uri);
200
        }
201
    }
202
203
    /**
204
     * Build redirect URI for removal operation.

source/Snapshotter/FileHandler/Controllers/SnapshotsController.php 1 location

@@ 116-140 (lines=25) @@
113
     * @param ServerRequestInterface $request
114
     * @return array|\Psr\Http\Message\ResponseInterface
115
     */
116
    public function removeAction(SnapshotService $service, ServerRequestInterface $request)
117
    {
118
        $filename = $this->input->input('filename');
119
        $snapshot = $service->getSnapshot($filename);
120
121
        if (empty($snapshot)) {
122
            throw new NotFoundException;
123
        }
124
125
        $this->authorize('remove', compact('snapshot'));
126
127
        $service->deleteSnapshot($snapshot);
128
129
        $uri = $this->removeBackURI($request);
130
131
        if ($this->input->isAjax()) {
132
            return [
133
                'status'  => 200,
134
                'message' => $this->say('Snapshot deleted.'),
135
                'action'  => ['redirect' => $uri]
136
            ];
137
        } else {
138
            return $this->response->redirect($uri);
139
        }
140
    }
141
142
    /**
143
     * Build redirect URI for removal operation.