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

AggregateSpamScore   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 32
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A calculate() 0 10 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
}