Test Failed
Push — master ( bf1804...12692f )
by Hirofumi
03:59
created

JobAbandonedRequeue   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 39
loc 39
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A handle() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Shippinno\Job\Infrastructure\Ui\Console\Laravel\Command;
4
5
use Doctrine\Common\Persistence\ManagerRegistry;
6
use Illuminate\Console\Command;
7
use Shippinno\Job\Application\Messaging\RequeueAbandonedJobMessageService;
8
use Shippinno\Job\Infrastructure\Persistence\Doctrine\ManagerRegistryAwareTrait;
9
10 View Code Duplication
class JobAbandonedRequeue extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    use ManagerRegistryAwareTrait;
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected $signature = 'job:abandoned:requeue {id}';
18
19
    /**
20
     * @var RequeueAbandonedJobMessageService
21
     */
22
    private $requeueAbandonedJobMessageService;
23
24
    /**
25
     * @param RequeueAbandonedJobMessageService $requeueAbandonedJobMessageService
26
     * @param ManagerRegistry|null $managerRegistry
27
     */
28
    public function __construct(
29
        RequeueAbandonedJobMessageService $requeueAbandonedJobMessageService,
30
        ManagerRegistry $managerRegistry = null
31
    ) {
32
        parent::__construct();
33
        $this->requeueAbandonedJobMessageService = $requeueAbandonedJobMessageService;
34
        $this->setManagerRegistry($managerRegistry);
35
    }
36
37
    /**
38
     * @throws \Shippinno\Job\Domain\Model\AbandonedJobMessageFailedToRequeueException
39
     * @throws \Shippinno\Job\Domain\Model\AbandonedJobMessageNotFoundException
40
     */
41
    public function handle()
42
    {
43
        $id = intval($this->argument('id'));
44
        $this->requeueAbandonedJobMessageService->execute($id);
45
        $this->flush();
46
        $this->info('Message has been successfully enqueued and the abandoned has been deleted.');
47
    }
48
}
49