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

SpamDecideScore   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 51
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isHam() 0 4 1
A isSpam() 0 4 1
A isLikelySpam() 0 4 2
1
<?php
2
3
namespace Genkgo\Mail\Protocol\Smtp;
4
5
/**
6
 * Class SpamDecideScore
7
 * @package Genkgo\Mail\Protocol\Smtp
8
 */
9
final class SpamDecideScore
10
{
11
12
    /**
13
     * @var int
14
     */
15
    private $ham;
16
    /**
17
     * @var int
18
     */
19
    private $spam;
20
21
    /**
22
     * SpamDecideScore constructor.
23
     * @param int $ham
24
     * @param int $spam
25
     */
26
    public function __construct(int $ham, int $spam)
27
    {
28
        $this->ham = $ham;
29
        $this->spam = $spam;
30
    }
31
32
    /**
33
     * @param int $score
34
     * @return bool
35
     */
36
    public function isHam(int $score): bool
37
    {
38
        return $this->ham > $score;
39
    }
40
41
    /**
42
     * @param int $score
43
     * @return bool
44
     */
45
    public function isSpam(int $score): bool
46
    {
47
        return $this->spam < $score;
48
    }
49
50
    /**
51
     * @param int $score
52
     * @return bool
53
     */
54
    public function isLikelySpam(int $score): bool
55
    {
56
        return $this->ham <= $score && $this->spam >= $score;
57
    }
58
59
}