Completed
Push — master ( 5840b0...fcc03f )
by Frederik
04:51
created

AggregateSpamScore::calculate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
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 1
    public function __construct(array $checkers)
21
    {
22 1
        $this->checkers = $checkers;
23 1
    }
24
25
    /**
26
     * @param MessageInterface $message
27
     * @return int
28
     */
29 1
    public function calculate(MessageInterface $message): int
30
    {
31 1
        $score = 0;
32
33 1
        foreach ($this->checkers as $check) {
34 1
            $score += $check->calculate($message);
35
        }
36
37 1
        return $score;
38
    }
39
}