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

AwsSesBounceComplaintHandler::saveComplainedEmailsToDB()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

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