Test Failed
Pull Request — master (#123)
by Maximo
06:15
created

Subscription::toMail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 5
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
11
class Subscription extends Notification implements NotificationInterfase
12
{
13
    //protected $useQueue = true;
14
15
    /**
16
     * Notification msg.
17
     *
18
     * @return string
19
     */
20
    public function message(): string
21
    {
22
        $app = Di::getDefault()->getApp();
23
24
        return 'Hi ' . $this->toUser->firstname . ' your subscription to the App ' . $app->name . ' will expire at ' . $this->entity->subscription->trial_ends_at;
25
    }
26
27
    /**
28
     * Email body.
29
     *
30
     * @return Message|null
31
     */
32
    public function toMail(): ?Message
33
    {
34
        return $this->mail->to($this->toUser->getEmail())
35
            ->subject('Subscription Expiration Notice')
36
            ->content($this->message());
37
    }
38
}
39