Completed
Pull Request — master (#17)
by Frederik
13:03
created

AggregateSpamScore::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Genkgo\Mail\Protocol\Smtp\SpamScore;
4
5
use Genkgo\Mail\MessageInterface;
6
use Genkgo\Mail\Protocol\Smtp\SpamScoreInterface;
7
8
final class AggregateSpamScore implements SpamScoreInterface
9
{
10
11
    /**
12
     * @var SpamScoreInterface[]
13
     */
14
    private $checkers;
15
16
    /**
17
     * AggregateSpamCheck constructor.
18
     * @param array $checkers
19
     */
20
    public function __construct(array $checkers)
21
    {
22
        $this->checkers = $checkers;
23
    }
24
25
    /**
26
     * @param MessageInterface $message
27
     * @return int
28
     */
29
    public function calculate(MessageInterface $message): int
30
    {
31
        $score = 0;
32
33
        foreach ($this->checkers as $check) {
34
            $score += $check->calculate($message);
35
        }
36
37
        return $score;
38
    }
39
}