Code Duplication    Length = 29-29 lines in 2 locations

DependencyInjection/Compiler/WorkerCompilerPass.php 2 locations

@@ 234-262 (lines=29) @@
231
        return $jobClass;
232
    }
233
234
    public function getRunClass(ContainerBuilder $container)
235
    {
236
        $runClass = $container->hasParameter('dtc_queue.class_run') ? $container->getParameter('dtc_queue.class_run') : null;
237
        if (!$runClass) {
238
            switch ($defaultType = $container->getParameter('dtc_queue.default_manager')) {
239
                case 'mongodb':
240
                    $runClass = 'Dtc\\QueueBundle\\Document\\Run';
241
                    break;
242
                case 'orm':
243
                    $runClass = 'Dtc\\QueueBundle\\Entity\\Run';
244
                    break;
245
                default:
246
                    $runClass = 'Dtc\\QueueBundle\\Model\\Run';
247
            }
248
        }
249
250
        if (isset($runClass)) {
251
            if (!class_exists($runClass)) {
252
                throw new \Exception("Can't find Run class $runClass");
253
            }
254
        }
255
256
        $test = new $runClass();
257
        if (!$test instanceof Run) {
258
            throw new \Exception("$runClass must be instance of (or derived from) Dtc\\QueueBundle\\Model\\Run");
259
        }
260
261
        return $runClass;
262
    }
263
264
    public function getRunArchiveClass(ContainerBuilder $container)
265
    {
@@ 264-292 (lines=29) @@
261
        return $runClass;
262
    }
263
264
    public function getRunArchiveClass(ContainerBuilder $container)
265
    {
266
        $runArchiveClass = $container->hasParameter('dtc_queue.class_run_archive') ? $container->getParameter('dtc_queue.class_run_archive') : null;
267
        if (!$runArchiveClass) {
268
            switch ($defaultType = $container->getParameter('dtc_queue.default_manager')) {
269
                case 'mongodb':
270
                    $runArchiveClass = 'Dtc\\QueueBundle\\Document\\RunArchive';
271
                    break;
272
                case 'orm':
273
                    $runArchiveClass = 'Dtc\\QueueBundle\\Entity\\RunArchive';
274
                    break;
275
                default:
276
                    $runArchiveClass = 'Dtc\\QueueBundle\\Model\\Run';
277
            }
278
        }
279
280
        if (isset($runArchiveClass)) {
281
            if (!class_exists($runArchiveClass)) {
282
                throw new \Exception("Can't find RunArchive class $runArchiveClass");
283
            }
284
        }
285
286
        $test = new $runArchiveClass();
287
        if (!$test instanceof Run) {
288
            throw new \Exception("$runArchiveClass must be instance of (or derived from) Dtc\\QueueBundle\\Model\\Run");
289
        }
290
291
        return $runArchiveClass;
292
    }
293
294
    /**
295
     * Determines the job class based on the queue manager type.