Test Failed
Pull Request — master (#163)
by Rafael
06:40
created

ResetPassword::toMail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Notifications;
6
7
use Canvas\Contracts\Notifications\NotificationInterfase;
8
use Baka\Mail\Message;
9
use Phalcon\Di;
10
use Canvas\Models\Users;
11
12
class ResetPassword extends Notification implements NotificationInterfase
13
{
14
    //protected $useQueue = true;
15
16
    /**
17
     * Notification msg.
18
     *
19
     * @return string
20
     */
21
    public function message(): string
22
    {
23
        $app = Di::getDefault()->getApp();
24
25
        $userExists = Users::findFirst([
26
            'conditions' => 'email = ?0 and is_deleted = 0',
27
            'bind' => [$this->entity->email]
28
        ]);
29
30
        if (is_object($userExists)) {
31
            $resetPasswordUrl = $app->url . '/user/reset/' . $userExists->user_activation_key;
32
        }
33
34
        return "Hi {$this->entity->email}, click the following link to reset your password: <a href='{$resetPasswordUrl}'>Reset Password</a> <br /><br />
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $resetPasswordUrl does not seem to be defined for all execution paths leading up to this point.
Loading history...
35
                Thanks {$this->fromUser->firstname} {$this->fromUser->lastname} ( {$this->fromUser->currentCompany->name} ) ";
36
    }
37
38
    /**
39
     * Email body.
40
     *
41
     * @return Message|null
42
     */
43
    public function toMail(): ?Message
44
    {
45
        // return $this->mail->to($this->toUser->getEmail())
46
        //     ->subject('Password Updated')
47
        //     ->content($this->message());
48
        
49
        return $this->mail->to('[email protected]')
50
        ->subject('Password Updated')
51
        ->content($this->message());
52
    }
53
}
54