控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Result.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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;
  18. /**
  19. * <p>Encapsulates the result of decoding a barcode within an image.</p>
  20. *
  21. * @author Sean Owen
  22. */
  23. final class Result
  24. {
  25. /**
  26. * @var mixed[]|mixed
  27. */
  28. private $resultMetadata = null;
  29. private $timestamp;
  30. public function __construct(
  31. private $text,
  32. private $rawBytes,
  33. private $resultPoints,
  34. private $format,
  35. $timestamp = ''
  36. ) {
  37. $this->timestamp = $timestamp ?: time();
  38. }
  39. /**
  40. * @return raw text encoded by the barcode
  41. */
  42. public function getText()
  43. {
  44. return $this->text;
  45. }
  46. /**
  47. * @return raw bytes encoded by the barcode, if applicable, otherwise {@code null}
  48. */
  49. public function getRawBytes()
  50. {
  51. return $this->rawBytes;
  52. }
  53. /**
  54. * @return points related to the barcode in the image. These are typically points
  55. * identifying finder patterns or the corners of the barcode. The exact meaning is
  56. * specific to the type of barcode that was decoded.
  57. */
  58. public function getResultPoints()
  59. {
  60. return $this->resultPoints;
  61. }
  62. /**
  63. * @return {@link BarcodeFormat} representing the format of the barcode that was decoded
  64. */
  65. public function getBarcodeFormat()
  66. {
  67. return $this->format;
  68. }
  69. /**
  70. * @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be
  71. * {@code null}. This contains optional metadata about what was detected about the barcode,
  72. * like orientation.
  73. */
  74. public function getResultMetadata()
  75. {
  76. return $this->resultMetadata;
  77. }
  78. public function putMetadata($type, $value): void
  79. {
  80. $resultMetadata = [];
  81. if ($this->resultMetadata === null) {
  82. $this->resultMetadata = [];
  83. }
  84. $resultMetadata[$type] = $value;
  85. }
  86. public function putAllMetadata($metadata): void
  87. {
  88. if ($metadata !== null) {
  89. if ($this->resultMetadata === null) {
  90. $this->resultMetadata = $metadata;
  91. } else {
  92. $this->resultMetadata = array_merge($this->resultMetadata, $metadata);
  93. }
  94. }
  95. }
  96. public function addResultPoints($newPoints): void
  97. {
  98. $oldPoints = $this->resultPoints;
  99. if ($oldPoints === null) {
  100. $this->resultPoints = $newPoints;
  101. } elseif ($newPoints !== null && (is_countable($newPoints) ? count($newPoints) : 0) > 0) {
  102. $allPoints = fill_array(0, (is_countable($oldPoints) ? count($oldPoints) : 0) + (is_countable($newPoints) ? count($newPoints) : 0), 0);
  103. $allPoints = arraycopy($oldPoints, 0, $allPoints, 0, is_countable($oldPoints) ? count($oldPoints) : 0);
  104. $allPoints = arraycopy($newPoints, 0, $allPoints, is_countable($oldPoints) ? count($oldPoints) : 0, is_countable($newPoints) ? count($newPoints) : 0);
  105. $this->resultPoints = $allPoints;
  106. }
  107. }
  108. public function getTimestamp()
  109. {
  110. return $this->timestamp;
  111. }
  112. public function toString()
  113. {
  114. return $this->text;
  115. }
  116. }