Exemple #1
0
 /**
  * Write PHP array, as table. Input array format: keys are strings,
  * values are (type,value) tuples.
  *
  * @param AMQPTable|array $d Instance of AMQPTable or PHP array WITH format hints (unlike write_array())
  * @return $this
  * @throws \PhpAmqpLib\Exception\AMQPInvalidArgumentException
  */
 public function write_table($d)
 {
     $typeIsSym = !$d instanceof AMQPTable;
     //purely for back-compat purposes
     $table_data = new AMQPWriter();
     foreach ($d as $k => $va) {
         list($ftype, $v) = $va;
         $table_data->write_shortstr($k);
         $table_data->write_value($typeIsSym ? AMQPAbstractCollection::getDataTypeForSymbol($ftype) : $ftype, $v);
     }
     $table_data = $table_data->getvalue();
     $this->write_long(mb_strlen($table_data, 'ASCII'));
     $this->write($table_data);
     return $this;
 }