Completed
Pull Request — master (#17)
by Frederik
13:15 queued 08:17
created

SpamDecideScore::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 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
}