NotificationService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 63
rs 10
c 2
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A sendEmailExpiringEvent() 0 4 1
A sendEmailGetATreatment() 0 6 1
A sendEmailContactMe() 0 6 1
A sendEmailNewTestimonial() 0 6 1
1
<?php
2
3
namespace App\Services;
4
5
use App\Models\Event;
6
use App\Models\User;
7
use App\Notifications\ContactMeMailNotification;
8
use App\Notifications\ExpiringEventMailNotification;
9
use App\Notifications\GetATreatmentMailNotification;
10
use App\Notifications\NewTestimonialMailNotification;
11
12
class NotificationService
13
{
14
15
    /**
16
     * Send an email when the contact form is submitted
17
     *
18
     * @param array $data
19
     * @param int $userId
20
     *
21
     * @return bool
22
     */
23
    public function sendEmailContactMe(array $data, int $userId): bool
24
    {
25
        $user = User::find($userId);
26
        $user->notify(new ContactMeMailNotification($data));
27
28
        return true;
29
    }
30
31
    /**
32
     * Send an email when the get a treatment form is submitted
33
     *
34
     * @param array $data
35
     * @param int $userId
36
     *
37
     * @return bool
38
     */
39
    public function sendEmailGetATreatment(array $data, int $userId): bool
40
    {
41
        $user = User::find($userId);
42
        $user->notify(new GetATreatmentMailNotification($data));
43
44
        return true;
45
    }
46
47
    /**
48
     * Send an email when the new testimonial form is submitted
49
     *
50
     * @param  array  $data
51
     * @param  int  $userId
52
     *
53
     * @return bool
54
     */
55
    public function sendEmailNewTestimonial(array $data, int $userId): bool
56
    {
57
        $user = User::find($userId);
58
        $user->notify(new NewTestimonialMailNotification($data));
59
60
        return true;
61
    }
62
63
    /**
64
     * Send an email to expiring event organizer
65
     *
66
     * @param  array  $data
67
     * @param  Event  $event
68
     *
69
     * @return bool
70
     */
71
    public function sendEmailExpiringEvent(array $data, Event $event): bool
72
    {
73
        $event->user->notify(new ExpiringEventMailNotification($data, $event));
74
        return true;
75
    }
76
}
77