mxmbsocket/src/Socket/Session/Serialize/PhpBinaryHandler.php
Mohamad Faeez 50725bbf4c
Some checks are pending
CI / PHPUnit (highest, 5.4) (push) Waiting to run
CI / PHPUnit (highest, 5.5) (push) Waiting to run
CI / PHPUnit (highest, 5.6) (push) Waiting to run
CI / PHPUnit (highest, 7.0) (push) Waiting to run
CI / PHPUnit (highest, 7.1) (push) Waiting to run
CI / PHPUnit (highest, 7.2) (push) Waiting to run
CI / PHPUnit (highest, 7.3) (push) Waiting to run
CI / PHPUnit (highest, 7.4) (push) Waiting to run
CI / PHPUnit (lowest, 5.4) (push) Waiting to run
major update
2025-04-09 14:56:59 +08:00

34 lines
929 B
PHP

<?php
namespace mfmdevsystem\socket\Session\Serialize;
class PhpBinaryHandler implements HandlerInterface {
/**
* {@inheritdoc}
*/
function serialize(array $data) {
throw new \RuntimeException("Serialize PhpHandler:serialize code not written yet, write me!");
}
/**
* {@inheritdoc}
* @link http://ca2.php.net/manual/en/function.session-decode.php#108037 Code from this comment on php.net
*/
public function unserialize($raw) {
$returnData = array();
$offset = 0;
while ($offset < strlen($raw)) {
$num = ord($raw[$offset]);
$offset += 1;
$varname = substr($raw, $offset, $num);
$offset += $num;
$data = unserialize(substr($raw, $offset));
$returnData[$varname] = $data;
$offset += strlen(serialize($data));
}
return $returnData;
}
}