Code Duplication    Length = 15-17 lines in 6 locations

src/Comodojo/Extender/Schedule/Manager.php 6 locations

@@ 195-209 (lines=15) @@
192
193
    }
194
195
    public function remove($id) {
196
197
        $em = $this->getEntityManager();
198
199
        $schedule = $this->get($id);
200
201
        if ( is_null($schedule) ) throw new Exception("Cannot find scheule $id");
202
203
        $em->remove($schedule);
204
205
        $em->flush();
206
207
        return true;
208
209
    }
210
211
    public function removeByName($name) {
212
@@ 211-225 (lines=15) @@
208
209
    }
210
211
    public function removeByName($name) {
212
213
        $em = $this->getEntityManager();
214
215
        $schedule = $this->getByName($name);
216
217
        if ( is_null($schedule) ) throw new Exception("Cannot find scheule $name");
218
219
        $em->remove($schedule);
220
221
        $em->flush();
222
223
        return true;
224
225
    }
226
227
    public function enable($id) {
228
@@ 227-243 (lines=17) @@
224
225
    }
226
227
    public function enable($id) {
228
229
        $em = $this->getEntityManager();
230
231
        $schedule = $this->get($id);
232
233
        if ( is_null($schedule) ) throw new Exception("Cannot find scheule $id");
234
235
        $schedule->setEnabled(true);
236
237
        $em->persist($schedule);
238
239
        $em->flush();
240
241
        return true;
242
243
    }
244
245
    public function enableByName($name) {
246
@@ 245-261 (lines=17) @@
242
243
    }
244
245
    public function enableByName($name) {
246
247
        $em = $this->getEntityManager();
248
249
        $schedule = $this->getByName($name);
250
251
        if ( is_null($schedule) ) throw new Exception("Cannot find scheule $name");
252
253
        $schedule->setEnabled(true);
254
255
        $em->persist($schedule);
256
257
        $em->flush();
258
259
        return true;
260
261
    }
262
263
    public function disable($id) {
264
@@ 263-279 (lines=17) @@
260
261
    }
262
263
    public function disable($id) {
264
265
        $em = $this->getEntityManager();
266
267
        $schedule = $this->get($id);
268
269
        if ( is_null($schedule) ) throw new Exception("Cannot find scheule $id");
270
271
        $schedule->setEnabled(false);
272
273
        $em->persist($schedule);
274
275
        $em->flush();
276
277
        return true;
278
279
    }
280
281
    public function disableByName($name) {
282
@@ 281-297 (lines=17) @@
278
279
    }
280
281
    public function disableByName($name) {
282
283
        $em = $this->getEntityManager();
284
285
        $schedule = $this->getByName($name);
286
287
        if ( is_null($schedule) ) throw new Exception("Cannot find scheule $name");
288
289
        $schedule->setEnabled(false);
290
291
        $em->persist($schedule);
292
293
        $em->flush();
294
295
        return true;
296
297
    }
298
299
}
300