Completed
Push — master ( 289935...a2cbf9 )
by Mahmoud
04:10
created

SetVisitorEmailAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 3
dl 59
loc 59
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A run() 8 8 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 App\Containers\Email\Actions;
4
5
use App\Containers\Email\Services\GenerateEmailConfirmationUrlService;
6
use App\Containers\Email\Services\SendConfirmationEmailService;
7
use App\Containers\Email\Services\SetUserEmailService;
8
use App\Containers\User\Services\FindUserService;
9
use App\Port\Action\Abstracts\Action;
10
11
/**
12
 * Class SetVisitorEmailAction.
13
 *
14
 * @author Mahmoud Zalt <[email protected]>
15
 */
16 View Code Duplication
class SetVisitorEmailAction extends Action
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...
17
{
18
19
    /**
20
     * @var  \App\Containers\Email\Services\SetUserEmailService
21
     */
22
    private $setUserEmailService;
23
24
    /**
25
     * @var  \App\Containers\Email\Services\GenerateEmailConfirmationUrlService
26
     */
27
    private $generateEmailConfirmationUrlService;
28
29
    /**
30
     * @var  \App\Containers\Email\Services\SendConfirmationEmailService
31
     */
32
    private $sendConfirmationEmailService;
33
34
    /**
35
     * @var  \App\Containers\User\Services\FindUserService
36
     */
37
    private $findUserService;
38
39
    /**
40
     * SetUserEmailAction constructor.
41
     *
42
     * @param \App\Containers\Email\Services\SetUserEmailService                 $setUserEmailService
43
     * @param \App\Containers\Email\Services\GenerateEmailConfirmationUrlService $generateEmailConfirmationUrlService
44
     * @param \App\Containers\Email\Services\SendConfirmationEmailService        $sendConfirmationEmailService
45
     * @param \App\Containers\User\Services\FindUserService                      $findUserService
46
     */
47
    public function __construct(
48
        SetUserEmailService $setUserEmailService,
49
        GenerateEmailConfirmationUrlService $generateEmailConfirmationUrlService,
50
        SendConfirmationEmailService $sendConfirmationEmailService,
51
        FindUserService $findUserService
52
    ) {
53
        $this->setUserEmailService = $setUserEmailService;
54
        $this->generateEmailConfirmationUrlService = $generateEmailConfirmationUrlService;
55
        $this->sendConfirmationEmailService = $sendConfirmationEmailService;
56
        $this->findUserService = $findUserService;
57
    }
58
59
60
    /**
61
     * @param $userId
62
     * @param $email
63
     *
64
     * @return  bool
65
     */
66
    public function run($visitorId, $email)
67
    {
68
        $user = $this->findUserService->byVisitorId($visitorId);
69
70
        $this->setUserEmailService->run($user->id, $email);
71
72
        return true;
73
    }
74
}
75