From 4258966a8dfded01c18ad1a67815b472165e7be5 Mon Sep 17 00:00:00 2001 From: smiley Date: Tue, 26 Jul 2022 17:11:17 +0200 Subject: [PATCH] :octocat: return QRMatrix created from result data --- src/Decoder/DecoderResult.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Decoder/DecoderResult.php b/src/Decoder/DecoderResult.php index 8a9fdb222..0a4a669ac 100644 --- a/src/Decoder/DecoderResult.php +++ b/src/Decoder/DecoderResult.php @@ -11,7 +11,8 @@ namespace chillerlan\QRCode\Decoder; -use chillerlan\QRCode\Common\{EccLevel, MaskPattern, Version}; +use chillerlan\QRCode\Data\QRMatrix; +use chillerlan\QRCode\Common\{BitBuffer, EccLevel, MaskPattern, Version}; use function property_exists; /** @@ -83,4 +84,15 @@ final class DecoderResult{ return $this->structuredAppendParity >= 0 && $this->structuredAppendSequence >= 0; } + /** + * Returns a QRMatrix instance with thesettings and data of the reader result + */ + public function getMatrix():QRMatrix{ + return (new QRMatrix($this->version, $this->eccLevel, $this->maskPattern)) + ->initFunctionalPatterns() + ->writeCodewords(new BitBuffer($this->rawBytes)) + ->mask() + ; + } + }