|
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\Settings\SettingsContainerAbstract; |
|
15
|
|
|
use chillerlan\QRCode\Common\{EccLevel, Version}; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Encapsulates the result of decoding a matrix of bits. This typically |
|
19
|
|
|
* applies to 2D barcode formats. For now it contains the raw bytes obtained, |
|
20
|
|
|
* as well as a String interpretation of those bytes, if applicable. |
|
21
|
|
|
* |
|
22
|
|
|
* @property int[] $rawBytes |
|
23
|
|
|
* @property string $text |
|
24
|
|
|
* @property \chillerlan\QRCode\Common\Version $version |
|
25
|
|
|
* @property \chillerlan\QRCode\Common\EccLevel $eccLevel |
|
26
|
|
|
* @property int $structuredAppendParity |
|
27
|
|
|
* @property int $structuredAppendSequence |
|
28
|
|
|
*/ |
|
29
|
|
|
final class DecoderResult extends SettingsContainerAbstract{ |
|
30
|
|
|
|
|
31
|
|
|
protected array $rawBytes; |
|
32
|
|
|
protected string $text; |
|
33
|
|
|
protected Version $version; |
|
34
|
|
|
protected EccLevel $eccLevel; |
|
35
|
|
|
protected int $structuredAppendParity = -1; |
|
36
|
|
|
protected int $structuredAppendSequence = -1; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @inheritDoc |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __set($property, $value):void{ |
|
42
|
|
|
// noop, read-only |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @inheritDoc |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __toString():string{ |
|
49
|
|
|
return $this->text; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @inheritDoc |
|
54
|
|
|
*/ |
|
55
|
|
|
public function fromIterable(iterable $properties):self{ |
|
56
|
|
|
|
|
57
|
|
|
foreach($properties as $key => $value){ |
|
58
|
|
|
parent::__set($key, $value); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $this; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* |
|
66
|
|
|
*/ |
|
67
|
|
|
public function hasStructuredAppend():bool{ |
|
68
|
|
|
return $this->structuredAppendParity >= 0 && $this->structuredAppendSequence >= 0; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|