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

AwsSesBounceComplaintHandler::storeEmailToDB()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.0067

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 3
nop 1
dl 0
loc 18
ccs 10
cts 11
cp 0.9091
crap 3.0067
rs 9.9
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