PhpAmqpLib\Wire\GenericContent::serialize_properties PHP Метод

serialize_properties() публичный Метод

Serializes the 'properties' attribute (a dictionary) into the raw bytes making up a set of property flags and a property list, suitable for putting into a content frame header.
public serialize_properties ( ) : string
Результат string
    public function serialize_properties()
    {
        if (!empty($this->serialized_properties)) {
            return $this->serialized_properties;
        }
        $shift = 15;
        $flag_bits = 0;
        $flags = array();
        $raw_bytes = new AMQPWriter();
        foreach ($this->prop_types as $key => $prototype) {
            $val = isset($this->properties[$key]) ? $this->properties[$key] : null;
            // Very important: PHP type eval is weak, use the === to test the
            // value content. Zero or false value should not be removed
            if ($val === null) {
                $shift -= 1;
                continue;
            }
            if ($shift === 0) {
                $flags[] = $flag_bits;
                $flag_bits = 0;
                $shift = 15;
            }
            $flag_bits |= 1 << $shift;
            if ($prototype != 'bit') {
                $raw_bytes->{'write_' . $prototype}($val);
            }
            $shift -= 1;
        }
        $flags[] = $flag_bits;
        $result = new AMQPWriter();
        foreach ($flags as $flag_bits) {
            $result->write_short($flag_bits);
        }
        $result->write($raw_bytes->getvalue());
        $this->serialized_properties = $result->getvalue();
        return $this->serialized_properties;
    }