| <?php |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| namespace Zxing; |
|
|
| |
| |
| |
| |
| |
| final class Result |
| { |
| private $text; |
| private $rawBytes; |
| private $resultPoints; |
| private $format; |
| private $resultMetadata; |
| private $timestamp; |
|
|
| public function __construct( |
| $text, |
| $rawBytes, |
| $resultPoints, |
| $format, |
| $timestamp = '' |
| ) { |
|
|
| $this->text = $text; |
| $this->rawBytes = $rawBytes; |
| $this->resultPoints = $resultPoints; |
| $this->format = $format; |
| $this->resultMetadata = null; |
| $this->timestamp = $timestamp ?: time(); |
| } |
|
|
| |
| |
| |
| public function getText() |
| { |
| return $this->text; |
| } |
|
|
| |
| |
| |
| public function getRawBytes() |
| { |
| return $this->rawBytes; |
| } |
|
|
| |
| |
| |
| |
| |
| public function getResultPoints() |
| { |
| return $this->resultPoints; |
| } |
|
|
| |
| |
| |
| public function getBarcodeFormat() |
| { |
| return $this->format; |
| } |
|
|
| |
| |
| |
| |
| |
| public function getResultMetadata() |
| { |
| return $this->resultMetadata; |
| } |
|
|
| public function putMetadata($type, $value) |
| { |
| if ($this->resultMetadata === null) { |
| $this->resultMetadata = []; |
| } |
| $resultMetadata[$type] = $value; |
| } |
|
|
| public function putAllMetadata($metadata) |
| { |
| if ($metadata !== null) { |
| if ($this->resultMetadata === null) { |
| $this->resultMetadata = $metadata; |
| } else { |
| $this->resultMetadata = array_merge($this->resultMetadata, $metadata); |
| } |
| } |
| } |
|
|
| public function addResultPoints($newPoints) |
| { |
| $oldPoints = $this->resultPoints; |
| if ($oldPoints === null) { |
| $this->resultPoints = $newPoints; |
| } else if ($newPoints !== null && count($newPoints) > 0) { |
| $allPoints = fill_array(0, count($oldPoints) + count($newPoints), 0); |
| $allPoints = arraycopy($oldPoints, 0, $allPoints, 0, count($oldPoints)); |
| $allPoints = arraycopy($newPoints, 0, $allPoints, count($oldPoints), count($newPoints)); |
| $this->resultPoints = $allPoints; |
| } |
| } |
|
|
| public function getTimestamp() |
| { |
| return $this->timestamp; |
| } |
|
|
| public function toString() |
| { |
| return $this->text; |
| } |
| } |
|
|