Completed
Push — master ( 857394...4794c5 )
by Mahmoud
03:25
created

SendContactUsEmailTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 12 1
1
<?php
2
3
namespace App\Containers\Contact\Tasks;
4
5
use App\Containers\Contact\Mails\ContactUsEmail;
6
use App\Port\Task\Abstracts\Task;
7
8
/**
9
 * Class SendContactUsEmailTask.
10
 *
11
 * @author Mahmoud Zalt <[email protected]>
12
 */
13
class SendContactUsEmailTask extends Task
14
{
15
16
    /**
17
     * @var  \App\Containers\Contact\Mails\ContactUsEmail
18
     */
19
    private $email;
20
21
    /**
22
     * SampleAction constructor.
23
     *
24
     * @param \App\Containers\Contact\Mails\ContactUsEmail $contactUsEmail
25
     */
26
    public function __construct(ContactUsEmail $contactUsEmail)
27
    {
28
        $this->email = $contactUsEmail;
29
    }
30
31
    /**
32
     * @param        $fromEmail
33
     * @param        $message
34
     * @param string $subject
35
     * @param string $fromName
36
     *
37
     * @return  bool
38
     */
39
    public function run($fromEmail, $message, $subject = 'No Subject', $fromName = 'No Name')
40
    {
41
        $this->email->to(env('MAIL_TO_SUPPORT_ADDRESS'));
42
        $this->email->setSubject($subject);
43
        $result = $this->email->send([
44
            'email'   => $fromEmail,
45
            'name'    => $fromName,
46
            'content' => $message,
47
        ]);
48
49
        return $result;
50
    }
51
}
52