Completed
Push — master ( 4bb4eb...402013 )
by Arthur
03:35
created

Guess   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 65
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
A getConfidence() 0 4 1
1
<?php
2
3
namespace Arthem\GraphQLMapper\Mapping\Guess;
4
5
abstract class Guess
6
{
7
    /**
8
     * Marks an instance with a value that is extremely likely to be correct.
9
     *
10
     * @var int
11
     */
12
    const VERY_HIGH_CONFIDENCE = 3;
13
14
    /**
15
     * Marks an instance with a value that is very likely to be correct.
16
     *
17
     * @var int
18
     */
19
    const HIGH_CONFIDENCE = 2;
20
21
    /**
22
     * Marks an instance with a value that is likely to be correct.
23
     *
24
     * @var int
25
     */
26
    const MEDIUM_CONFIDENCE = 1;
27
28
    /**
29
     * Marks an instance with a value that may be correct.
30
     *
31
     * @var int
32
     */
33
    const LOW_CONFIDENCE = 0;
34
35
    /**
36
     * The confidence about the correctness of the value.
37
     *
38
     * One of VERY_HIGH_CONFIDENCE, HIGH_CONFIDENCE, MEDIUM_CONFIDENCE
39
     * and LOW_CONFIDENCE.
40
     *
41
     * @var int
42
     */
43
    private $confidence;
44
45
    /**
46
     * @param int $confidence
47
     */
48
    public function __construct($confidence = self::LOW_CONFIDENCE)
49
    {
50
        if (!in_array($confidence, [
51
            self::VERY_HIGH_CONFIDENCE,
52
            self::HIGH_CONFIDENCE,
53
            self::MEDIUM_CONFIDENCE,
54
            self::LOW_CONFIDENCE,
55
        ])
56
        ) {
57
            throw new \InvalidArgumentException('The confidence should be one of the constants defined in Guess.');
58
        }
59
        $this->confidence = $confidence;
60
    }
61
62
    /**
63
     * @return int
64
     */
65
    public function getConfidence()
66
    {
67
        return $this->confidence;
68
    }
69
}
70