/**
  * @param string $data
  * @param string $format
  * @param array  $context
  *
  * @return mixed
  */
 public function decode($data, $format, array $context = array())
 {
     $value = Encoder::decode($data, Encoder::TYPE_ARRAY);
     return $value;
 }
Example #2
0
 protected function _unpack($flag, $bytes)
 {
     $value = null;
     if ($this->_sourceLength < $this->_offset + $bytes) {
         $exception = new UbjsonDecodeException('invalid ubjson data');
         if ($this->_throwException) {
             throw $exception;
         }
         self::$_lastErrorMessage = $exception->getMessage();
     } else {
         $packed = $this->_read($bytes);
         switch ($flag) {
             case 's':
             case 'l':
             case 'f':
                 $swap = SYS_LITTLE_ENDIAN;
                 break;
             default:
                 $swap = false;
         }
         if ($swap) {
             $packed = strrev($packed);
         }
         list(, $value) = unpack($flag, $packed);
     }
     return $value;
 }