Passed
Push — master ( b9e179...1762c3 )
by George
04:42
created

AwsSesBounceComplaintHandler::handleBounceOrComplaint()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 31
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 6.0702

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 15
nc 6
nop 1
dl 0
loc 31
ccs 14
cts 16
cp 0.875
crap 6.0702
rs 9.2222
c 2
b 0
f 0
1
<?php
2
3
namespace ag84ark\AwsSesBounceComplaintHandler;
4
5
use ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail;
6
use Illuminate\Support\Collection;
7
8
class AwsSesBounceComplaintHandler
9
{
10 2
    public static function canSendToEmail(string $email): bool
11
    {
12
        /** @var WrongEmail[]|Collection $emails */
13 2
        $emails = WrongEmail::active()
14 2
            ->bounced()
15 2
            ->where('email', '=', $email)
16 2
            ->get();
17
18 2
        foreach ($emails as $wrongEmail) {
19 1
            if (! $wrongEmail->canBouncedSend()) {
20 1
                return false;
21
            }
22
        }
23
24 1
        return true;
25
    }
26
}
27