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

MailerHandler::isHandling()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 1
b 0
f 0
ccs 4
cts 4
cp 1
cc 4
nc 6
nop 1
crap 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