|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Class DecoderResult |
|
4
|
|
|
* |
|
5
|
|
|
* @created 17.01.2021 |
|
6
|
|
|
* @author ZXing Authors |
|
7
|
|
|
* @author Smiley <[email protected]> |
|
8
|
|
|
* @copyright 2021 Smiley |
|
9
|
|
|
* @license Apache-2.0 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace chillerlan\QRCode\Decoder; |
|
13
|
|
|
|
|
14
|
|
|
use chillerlan\QRCode\Common\{EccLevel, Version}; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* <p>Encapsulates the result of decoding a matrix of bits. This typically |
|
18
|
|
|
* applies to 2D barcode formats. For now it contains the raw bytes obtained, |
|
19
|
|
|
* as well as a String interpretation of those bytes, if applicable.</p> |
|
20
|
|
|
* |
|
21
|
|
|
* @author Sean Owen |
|
22
|
|
|
*/ |
|
23
|
|
|
final class DecoderResult{ |
|
24
|
|
|
|
|
25
|
|
|
private array $rawBytes; |
|
26
|
|
|
private string $text; |
|
27
|
|
|
private Version $version; |
|
28
|
|
|
private EccLevel $eccLevel; |
|
29
|
|
|
private int $structuredAppendParity; |
|
30
|
|
|
private int $structuredAppendSequenceNumber; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct( |
|
33
|
|
|
array $rawBytes, |
|
34
|
|
|
string $text, |
|
35
|
|
|
Version $version, |
|
36
|
|
|
EccLevel $eccLevel, |
|
37
|
|
|
int $saSequence = -1, |
|
38
|
|
|
int $saParity = -1 |
|
39
|
|
|
){ |
|
40
|
|
|
$this->rawBytes = $rawBytes; |
|
41
|
|
|
$this->text = $text; |
|
42
|
|
|
$this->version = $version; |
|
43
|
|
|
$this->eccLevel = $eccLevel; |
|
44
|
|
|
$this->structuredAppendParity = $saParity; |
|
45
|
|
|
$this->structuredAppendSequenceNumber = $saSequence; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @return int[] raw bytes encoded by the barcode, if applicable, otherwise {@code null} |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getRawBytes():array{ |
|
52
|
|
|
return $this->rawBytes; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return string raw text encoded by the barcode |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getText():string{ |
|
59
|
|
|
return $this->text; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function __toString():string{ |
|
63
|
|
|
return $this->text; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getVersion():Version{ |
|
67
|
|
|
return $this->version; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function getEccLevel():EccLevel{ |
|
71
|
|
|
return $this->eccLevel; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function hasStructuredAppend():bool{ |
|
75
|
|
|
return $this->structuredAppendParity >= 0 && $this->structuredAppendSequenceNumber >= 0; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getStructuredAppendParity():int{ |
|
79
|
|
|
return $this->structuredAppendParity; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getStructuredAppendSequenceNumber():int{ |
|
83
|
|
|
return $this->structuredAppendSequenceNumber; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|