EmailViewed   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 2
A __construct() 0 2 1
1
<?php
2
3
namespace App\Listeners;
4
5
use App\Models\Email;
6
use jdavidbakr\MailTracker\Events\ViewEmailEvent;
7
8
class EmailViewed
9
{
10
    public function __construct()
11
    {
12
        //
13
    }
14
15
    public function handle(ViewEmailEvent $event)
16
    {
17
        $campaign_id = $event->sent_email->getHeader('X-Campaign-ID');
18
19
        if ($campaign_id) {
20
            $email = Email::where('message_id', $event->sent_email->message_id)->first();
21
            $email->opens = $email->opens + 1;
22
            $email->save();
23
        }
24
    }
25
}
26