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

SetVisitorEmailAction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 11
loc 11
rs 9.4285
cc 1
eloc 9
nc 1
nop 4
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