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

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