Log   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 5
Bugs 1 Features 0
Metric Value
eloc 8
dl 0
loc 20
rs 10
c 5
b 1
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A processLog() 0 13 4
1
<?php
2
3
namespace BeyondCode\Mailbox\Drivers;
4
5
use BeyondCode\Mailbox\Facades\Mailbox;
6
use BeyondCode\Mailbox\InboundEmail;
7
use Illuminate\Mail\Events\MessageSent;
8
9
class Log implements DriverInterface
10
{
11
    public function register()
12
    {
13
        app('events')->listen(MessageSent::class, [$this, 'processLog']);
14
    }
15
16
    public function processLog(MessageSent $event)
17
    {
18
        if (config('mail.driver') !== 'log' && config('mail.default') !== 'log') {
19
            return;
20
        }
21
22
        $message = version_compare(app()->version(), '9.0.0', '>') ? $event->sent->toString() : $event->message;
0 ignored issues
show
introduced by
The method version() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        $message = version_compare(app()->/** @scrutinizer ignore-call */ version(), '9.0.0', '>') ? $event->sent->toString() : $event->message;
Loading history...
23
24
        /** @var InboundEmail $modelClass */
25
        $modelClass = config('mailbox.model');
26
        $email = $modelClass::fromMessage($message);
27
28
        Mailbox::callMailboxes($email);
0 ignored issues
show
Bug introduced by
The method callMailboxes() does not exist on BeyondCode\Mailbox\Facades\Mailbox. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        Mailbox::/** @scrutinizer ignore-call */ 
29
                 callMailboxes($email);
Loading history...
29
    }
30
}
31