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