DecoderResult.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /*
  3. * Copyright 2007 ZXing authors
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. namespace Zxing\Common;
  18. /**
  19. * <p>Encapsulates the result of decoding a matrix of bits. This typically
  20. * applies to 2D barcode formats. For now it contains the raw bytes obtained,
  21. * as well as a String interpretation of those bytes, if applicable.</p>
  22. *
  23. * @author Sean Owen
  24. */
  25. final class DecoderResult
  26. {
  27. /**
  28. * @var mixed|null
  29. */
  30. private $errorsCorrected;
  31. /**
  32. * @var mixed|null
  33. */
  34. private $erasures;
  35. /**
  36. * @var mixed|null
  37. */
  38. private $other;
  39. public function __construct(private $rawBytes, private $text, private $byteSegments, private $ecLevel, private $structuredAppendSequenceNumber = -1, private $structuredAppendParity = -1)
  40. {
  41. }
  42. public function getRawBytes()
  43. {
  44. return $this->rawBytes;
  45. }
  46. public function getText()
  47. {
  48. return $this->text;
  49. }
  50. public function getByteSegments()
  51. {
  52. return $this->byteSegments;
  53. }
  54. public function getECLevel()
  55. {
  56. return $this->ecLevel;
  57. }
  58. public function getErrorsCorrected()
  59. {
  60. return $this->errorsCorrected;
  61. }
  62. public function setErrorsCorrected($errorsCorrected): void
  63. {
  64. $this->errorsCorrected = $errorsCorrected;
  65. }
  66. public function getErasures()
  67. {
  68. return $this->erasures;
  69. }
  70. public function setErasures($erasures): void
  71. {
  72. $this->erasures = $erasures;
  73. }
  74. public function getOther()
  75. {
  76. return $this->other;
  77. }
  78. public function setOther($other): void
  79. {
  80. $this->other = $other;
  81. }
  82. public function hasStructuredAppend()
  83. {
  84. return $this->structuredAppendParity >= 0 && $this->structuredAppendSequenceNumber >= 0;
  85. }
  86. public function getStructuredAppendParity()
  87. {
  88. return $this->structuredAppendParity;
  89. }
  90. public function getStructuredAppendSequenceNumber()
  91. {
  92. return $this->structuredAppendSequenceNumber;
  93. }
  94. }