/**
  * Initializing the object with its parsed value.
  *
  * Value is iterated and its values (and keys)
  * are getting contained by the object.
  *
  * @param array $value Value
  */
 public function __construct(array $value = null)
 {
     $this->value = array();
     if (!isset($value)) {
         return;
     }
     if (Bencode\Builder::isDictionary($value)) {
         foreach ($value as $key => $sub_value) {
             $this->contain($sub_value, new StringValue($key));
         }
     } else {
         foreach ($value as $sub_value) {
             $this->contain($sub_value);
         }
     }
 }
 /**
  * Returns a bencoded string that represents a .torrent file and can be
  * read by BitTorrent clients.
  *
  * First item in the $announce_list will be used in the 'announce' key of
  * the .torrent file, which is compatible with the BitTorrent specification
  * ('announce-list' is an unofficial extension).
  *
  * @return string
  */
 public function createTorrentFile()
 {
     $torrent_data = array();
     // Info
     self::addDataToTorrentFile($torrent_data, 'info', $this->getInfo());
     // Announce-list/Nodes
     if (self::addDataToTorrentFile($torrent_data, 'announce-list', Utils::listToListOfLists($this->announce_list))) {
         self::addDataToTorrentFile($torrent_data, 'announce', reset($this->announce_list));
     } else {
         self::addDataToTorrentFile($torrent_data, 'nodes', $this->nodes);
     }
     // Url-list
     self::addDataToTorrentFile($torrent_data, 'url-list', $this->url_list);
     // Created by
     self::addDataToTorrentFile($torrent_data, 'created-by', $this->created_by);
     return Builder::build($torrent_data);
 }