Files
wy/ZeedFramework/library/Firestone/Protocol/C2L/AccountTake.php
2026-01-07 11:40:41 +08:00

92 lines
2.6 KiB
PHP

<?php
/**
* Zeed Platform Project
* Based on Zeed Framework & Zend Framework.
*
* BTS - Billing Transaction Service
* CAS - Central Authentication Service
*
* LICENSE
* http://www.zeed.com.cn/license/
*
* @category Firestone_Protocol_C2L_AccountTake
* @package Firestone_Protocol_C2L_AccountTake
* @subpackage Firestone_Protocol_C2L
* @copyright Copyright (c) 2010 Zeed Technologies PRC Inc. (http://www.zeed.com.cn)
* @author Zeed Team (http://blog.zeed.com.cn)
* @since 2010-10-28
* @version SVN: $Id$
*/
class Firestone_Protocol_C2L_AccountTake extends Firestone_Protocol_QMEProtocolSendAbstract
{
const DATA_FORMAT = "a51a33V";
protected $_data = array(
'username' => '',
'password' => '',
'expired' => 0);
/**
* @return Firestone_Protocol_C2L_AccountTake
*/
public static function instance()
{
return parent::_instance();
}
/**
* 设置data
* @param array|string $key
* @param integer|string|null $val
* @return Firestone_Protocol_C2L_AccountTake
*/
public function setData($key, $val = null)
{
if (is_array($key) && ! is_numeric($key)) {
foreach ($key as $k => $v) {
$this->setData($k, $v);
}
} else {
if (! array_key_exists($key, $this->_data)) {
throw new Zeed_Exception("not match key");
return;
}
$this->_data[$key] = $val;
}
return $this;
}
/**
* 生产data二进制串
* @return Firestone_Protocol_C2L_AccountTake
*/
public function makeDataPack()
{
$this->_dataPackString = pack(self::DATA_FORMAT, $this->_data['username'], $this->_data['password'], $this->_data['expired']);
return $this;
}
/**
* 生成最终的二进制串
*/
public function makeReturnPackString($header, $data)
{
$this->setHeader($header)->setData($data);
$this->makeHeaderPack()->makeDataPack();
if ('' == $this->_headerPackString) {
throw new Zeed_Exception('headerPackString is empty');
return;
}
if ('' == $this->_dataPackString) {
throw new Zeed_Exception('dataPackString is empty');
return;
}
$this->_returnPackString = $this->_headerPackString . $this->_dataPackString;
return $this->_returnPackString;
}
}
// End ^ Native EOL ^ encoding