Esempio n. 1
0
 /**
  * Returns an encoded stream of a Dictionary element.
  *
  * @return string Encoded Dictionary
  */
 public function encode()
 {
     $buffer = 'd';
     foreach ($this->_buffer as $k => $v) {
         $key = new Byte();
         $key->read($k);
         if (is_array($v)) {
             $dictionary = false;
             foreach (array_keys($v) as $ak) {
                 if (!is_numeric($ak)) {
                     $dictionary = true;
                 }
             }
             if ($dictionary) {
                 $value = new Dictionary();
             } else {
                 $value = new BList();
             }
         } elseif (is_numeric($v)) {
             $value = new Integer();
         } else {
             $value = new Byte();
         }
         $value->read($v);
         $buffer .= $key->encode() . $value->encode();
     }
     $buffer .= 'e';
     return $buffer;
 }