AwsSesBounceComplaintHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 34
ccs 17
cts 17
cp 1
rs 10
c 2
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canSendToEmail() 0 15 3
A clearEmail() 0 4 1
A ignoreEmail() 0 8 2
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 3
    public function canSendToEmail(string $email): bool
11
    {
12
        /** @var WrongEmail[]|Collection $emails */
13 3
        $emails = WrongEmail::active()
14 3
            ->bounced()
15 3
            ->where('email', '=', $email)
16 3
            ->get();
17
18 3
        foreach ($emails as $wrongEmail) {
19 2
            if (! $wrongEmail->canBouncedSend()) {
20 2
                return false;
21
            }
22
        }
23
24 2
        return true;
25
    }
26
27 1
    public function ignoreEmail(string $email): void
28
    {
29
        /** @var WrongEmail[]|Collection $emails */
30 1
        $emails = WrongEmail::where('email', '=', $email)->get();
31
32 1
        foreach ($emails as $wrongEmail) {
33 1
            $wrongEmail->ignore = true;
0 ignored issues
show
Documentation Bug introduced by
The property $ignore was declared of type integer, but true is of type true. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
34 1
            $wrongEmail->save();
35
        }
36 1
    }
37
38 1
    public function clearEmail(string $email): void
39
    {
40
        /* @var WrongEmail[]|Collection $emails */
41 1
        WrongEmail::where('email', '=', $email)->delete();
42 1
    }
43
}
44