"; const STX = "\x02"; const ETX = "\x03"; protected $type = 2010; protected $modifierCode; protected $localTransactionTime; protected $tid; protected $xmlData = []; public function __construct(array $options = []) { Qs_Options::setOptions($this, $options); } public function getType() { return $this->type; } public function setType($type) { $this->type = $type; return $this; } public function getModifierCode() { return $this->modifierCode; } public function setModifierCode($modifierCode) { $this->modifierCode = $modifierCode; return $this; } public function getLocalTransactionTime() { if (null === $this->localTransactionTime) { $this->localTransactionTime = time(); } return $this->localTransactionTime; } /** * @param int $time * @return $this */ public function setLocalTransactionTime($time) { $this->localTransactionTime = $time; return $this; } public function getTid() { return $this->tid; } public function setTid($tid) { $this->tid = $tid; return $this; } abstract public function toArray(); public function __toString() { return implode(self::STRING_SEPARATOR, $this->toArray()); } public function toBinary() { return "\x02" . implode(self::FIELD_SEPARATOR, $this->toArray()) . "\x03"; } protected function renderXmlData() { $xml = ''; foreach ($this->xmlData as $field => $value) { $xml .= "[{$field}]{$value}[/{$field}]"; } return $xml; } public function getXmlData() { return $this->xmlData; } public function setXmlData($xmlData) { $this->xmlData = $xmlData; return $this; } public function mask($string, $context = null, $showLastDigits = null) { if (null === $context) { $context = $string; } if (null !== $showLastDigits) { $replacement = str_repeat('X', strlen($string) - $showLastDigits) . substr($string, -1 * $showLastDigits); } else { $replacement = str_repeat('X', strlen($string)); } return str_replace($string, $replacement, $context); } }