-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFieldConfidence.php
More file actions
76 lines (66 loc) · 1.97 KB
/
FieldConfidence.php
File metadata and controls
76 lines (66 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Mindee\Parsing\V2\Field;
enum FieldConfidence: string
{
case Certain = 'Certain';
case High = 'High';
case Medium = 'Medium';
case Low = 'Low';
/**
* @return integer Rank of the value.
*/
public function rank(): int
{
return match ($this) {
self::Low => 1,
self::Medium => 2,
self::High => 3,
self::Certain => 4,
};
}
/**
* Shorthand for the '<=' operator.
* @param FieldConfidence $other Other confidence value.
* @return boolean True if this confidence is lower than or equal to the other.
*/
public function lessThanOrEqual(FieldConfidence $other): bool
{
return $this->rank() <= $other->rank();
}
/**
* Shorthand for the '>=' operator.
* @param FieldConfidence $other Other confidence value.
* @return boolean True if this confidence is greater than or equal to the other.
*/
public function greaterThanOrEqual(FieldConfidence $other): bool
{
return $this->rank() >= $other->rank();
}
/**
* Shorthand for the '<' operator.
* @param FieldConfidence $other Other confidence value.
* @return boolean True if this confidence is lower than the other.
*/
public function lessThan(FieldConfidence $other): bool
{
return $this->rank() < $other->rank();
}
/**
* Shorthand for the '>' operator.
* @param FieldConfidence $other Other confidence value.
* @return boolean True if this confidence is greater than the other.
*/
public function greaterThan(FieldConfidence $other): bool
{
return $this->rank() > $other->rank();
}
/**
* Shorthand for the '==' operator.
* @param FieldConfidence $other Other confidence value.
* @return boolean True if this confidence is equal to the other.
*/
public function equal(FieldConfidence $other): bool
{
return $this === $other;
}
}