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

JobAbandonedDelete::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
crap 2
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\DeleteAbandonedJobMessageService;
8
use Shippinno\Job\Infrastructure\Persistence\Doctrine\ManagerRegistryAwareTrait;
9
10 View Code Duplication
class JobAbandonedDelete 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:delete {id}';
18
19
    /**
20
     * @var DeleteAbandonedJobMessageService
21
     */
22
    private $deleteAbandonedJobMessageService;
23
24
    /**
25
     * @param DeleteAbandonedJobMessageService $deleteAbandonedJobMessageService
26
     * @param ManagerRegistry|null $managerRegistry
27
     */
28
    public function __construct(
29
        DeleteAbandonedJobMessageService $deleteAbandonedJobMessageService,
30
        ManagerRegistry $managerRegistry = null
31
    ) {
32
        parent::__construct();
33
        $this->deleteAbandonedJobMessageService = $deleteAbandonedJobMessageService;
34
        $this->setManagerRegistry($managerRegistry);
35
    }
36
37
    /**
38
     * @throws \Shippinno\Job\Domain\Model\AbandonedJobMessageNotFoundException
39
     */
40
    public function handle()
41
    {
42
        $id = intval($this->argument('id'));
43
        $this->deleteAbandonedJobMessageService->execute($id);
44
        $this->flush();
45
        $this->info('Message has been deleted.');
46
    }
47
}
48