DecoderResult.php 2.6 KB

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