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

AggregateSpamScore   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 32
ccs 0
cts 12
cp 0
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
    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
}