Completed
Push — master ( 21b36f...33e787 )
by Mahmoud
03:36
created

UserCreatedEventHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace App\Containers\User\Events\Handlers;
4
5
use App\Containers\Email\Mails\WelcomeEmail;
6
use App\Containers\User\Events\Events\UserCreatedEvent;
7
use Illuminate\Contracts\Queue\ShouldQueue;
8
9
/**
10
 * Class UserCreatedEventHandler
11
 *
12
 * @author  Mahmoud Zalt  <[email protected]>
13
 */
14
class UserCreatedEventHandler implements ShouldQueue
15
{
16
17
    /**
18
     * @var  \App\Containers\Email\Mails\WelcomeEmail
19
     */
20
    private $welcomeEmail;
21
22
    /**
23
     * UserCreatedEventHandler constructor.
24
     *
25
     * @param \App\Containers\Email\Mails\WelcomeEmail $welcomeEmail
26
     */
27
    public function __construct(WelcomeEmail $welcomeEmail)
28
    {
29
        $this->welcomeEmail = $welcomeEmail;
30
    }
31
32
    /**
33
     * @param \App\Containers\User\Events\Events\UserCreatedEvent $event
34
     */
35
    public function handle(UserCreatedEvent $event)
36
    {
37
        $this->welcomeEmail->to($event->user->email, $event->user->name)->send([
38
            'name'    => $event->user->name,
39
            'appName' => 'Hello API'
40
        ]);
41
    }
42
}
43