DecoderResult.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. private $rawBytes;
  28. private $text;
  29. private $byteSegments;
  30. private $ecLevel;
  31. private $errorsCorrected;
  32. private $erasures;
  33. private $other;
  34. private $structuredAppendParity;
  35. private $structuredAppendSequenceNumber;
  36. public function __construct(
  37. $rawBytes,
  38. $text,
  39. $byteSegments,
  40. $ecLevel,
  41. $saSequence = -1,
  42. $saParity = -1
  43. ) {
  44. $this->rawBytes = $rawBytes;
  45. $this->text = $text;
  46. $this->byteSegments = $byteSegments;
  47. $this->ecLevel = $ecLevel;
  48. $this->structuredAppendParity = $saParity;
  49. $this->structuredAppendSequenceNumber = $saSequence;
  50. }
  51. public function getRawBytes()
  52. {
  53. return $this->rawBytes;
  54. }
  55. public function getText()
  56. {
  57. return $this->text;
  58. }
  59. public function getByteSegments()
  60. {
  61. return $this->byteSegments;
  62. }
  63. public function getECLevel()
  64. {
  65. return $this->ecLevel;
  66. }
  67. public function getErrorsCorrected()
  68. {
  69. return $this->errorsCorrected;
  70. }
  71. public function setErrorsCorrected($errorsCorrected)
  72. {
  73. $this->errorsCorrected = $errorsCorrected;
  74. }
  75. public function getErasures()
  76. {
  77. return $this->erasures;
  78. }
  79. public function setErasures($erasures)
  80. {
  81. $this->erasures = $erasures;
  82. }
  83. public function getOther()
  84. {
  85. return $this->other;
  86. }
  87. public function setOther($other)
  88. {
  89. $this->other = $other;
  90. }
  91. public function hasStructuredAppend()
  92. {
  93. return $this->structuredAppendParity >= 0 && $this->structuredAppendSequenceNumber >= 0;
  94. }
  95. public function getStructuredAppendParity()
  96. {
  97. return $this->structuredAppendParity;
  98. }
  99. public function getStructuredAppendSequenceNumber()
  100. {
  101. return $this->structuredAppendSequenceNumber;
  102. }
  103. }