1 | <?php |
||
2 | |||
3 | |||
4 | namespace coffeebreaks; |
||
5 | |||
6 | |||
7 | use PHPMailer\PHPMailer\Exception; |
||
8 | use PHPMailer\PHPMailer\PHPMailer; |
||
9 | use PHPMailer\PHPMailer\SMTP; |
||
10 | |||
11 | class Mail |
||
12 | { |
||
13 | |||
14 | private $mail; |
||
15 | private $result; |
||
16 | |||
17 | |||
18 | public function config(string $host, string $user, string $pass, int $port) |
||
19 | { |
||
20 | $this->mail = new PHPMailer(1); |
||
21 | $this->mail->isSMTP(); |
||
22 | $this->mail->Host = $host; |
||
23 | $this->mail->SMTPAuth = true; |
||
24 | $this->mail->Username = $user; |
||
25 | $this->mail->Password = $pass; |
||
26 | $this->mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; |
||
27 | $this->mail->Port = $port; |
||
28 | |||
29 | $this->mail->isHTML(true); |
||
30 | |||
31 | } |
||
32 | |||
33 | public function add(string $fromAdress, string $fromName, string $mailTo, string $subject, string $body) |
||
34 | { |
||
35 | $this->mail->setLanguage('br'); |
||
36 | $this->mail->setFrom($fromAdress, $fromName); |
||
37 | $this->mail->addAddress($mailTo); |
||
38 | $this->mail->Subject = $subject; |
||
39 | $this->mail->Body = $body; |
||
40 | return $this->send(); |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | |||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return mixed |
||
47 | */ |
||
48 | public function getResult() |
||
49 | { |
||
50 | return $this->result; |
||
51 | } |
||
52 | |||
53 | |||
54 | private function send() |
||
55 | { |
||
56 | try { |
||
57 | if ($this->mail->send()){ |
||
58 | $this->result = true; |
||
59 | |||
60 | }else{ |
||
61 | $this->result = false; |
||
62 | } |
||
63 | } catch (Exception $e){ |
||
64 | echo "Error email send:: ". $e->errorMessage(); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | } |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.