Esempio n. 1
0
 /**
  * Consumes AMQP table/array field value.
  *
  * @param Buffer $buffer
  * @return mixed
  */
 public function consumeFieldValue(Buffer $buffer)
 {
     $fieldType = $buffer->consumeUint8();
     switch ($fieldType) {
         case Constants::FIELD_BOOLEAN:
             return $buffer->consumeUint8() > 0;
         case Constants::FIELD_SHORT_SHORT_INT:
             return $buffer->consumeInt8();
         case Constants::FIELD_SHORT_SHORT_UINT:
             return $buffer->consumeUint8();
         case Constants::FIELD_SHORT_INT:
             return $buffer->consumeInt16();
         case Constants::FIELD_SHORT_UINT:
             return $buffer->consumeUint16();
         case Constants::FIELD_LONG_INT:
             return $buffer->consumeInt32();
         case Constants::FIELD_LONG_UINT:
             return $buffer->consumeUint32();
         case Constants::FIELD_LONG_LONG_INT:
             return $buffer->consumeInt64();
         case Constants::FIELD_LONG_LONG_UINT:
             return $buffer->consumeUint64();
         case Constants::FIELD_FLOAT:
             return $buffer->consumeFloat();
         case Constants::FIELD_DOUBLE:
             return $buffer->consumeDouble();
         case Constants::FIELD_DECIMAL_VALUE:
             return $this->consumeDecimalValue($buffer);
         case Constants::FIELD_SHORT_STRING:
             return $buffer->consume($buffer->consumeUint8());
         case Constants::FIELD_LONG_STRING:
             return $buffer->consume($buffer->consumeUint32());
         case Constants::FIELD_ARRAY:
             return $this->consumeArray($buffer);
         case Constants::FIELD_TIMESTAMP:
             return $this->consumeTimestamp($buffer);
         case Constants::FIELD_TABLE:
             return $this->consumeTable($buffer);
         case Constants::FIELD_NULL:
             return null;
         default:
             throw new ProtocolException(sprintf("Unhandled field type 0x%02x", $fieldType) . (ctype_print(chr($fieldType)) ? " ('" . chr($fieldType) . "')" : "") . ".");
     }
 }