Failed Conditions
Push — master ( 5f5e96...daf37e )
by Adrien
03:02
created

MailerHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 4
dl 0
loc 9
rs 10
c 1
b 0
f 0
ccs 4
cts 4
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A isHandling() 0 7 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Log\Handler;
6
7
use GraphQL\Error\Error;
8
use Monolog\Handler\SymfonyMailerHandler;
9
use Monolog\LogRecord;
10
11
/**
12
 * Normal mailer handler but ignores exceptions that are explicitly marked as ignored.
13
 */
14
class MailerHandler extends SymfonyMailerHandler
15
{
16 13
    public function isHandling(LogRecord $record): bool
17
    {
18 13
        $exception = $record->context['exception'] ?? null;
19
20 13
        $ignored = $exception instanceof NoMailLogging || ($exception instanceof Error && $exception->getPrevious() instanceof NoMailLogging);
21
22 13
        return !$ignored && parent::isHandling($record);
23
    }
24
}
25