public function __construct($url = null)
 {
     parent::__construct();
     if ($url) {
         $this->setUrl($url);
     }
 }
 /**
  * Декодує дані з torrent файла
  * @param TorrentFile $torrentFile
  * @param $data
  */
 public static function decode(TorrentFile $torrentFile, $data)
 {
     $torrent = $torrentFile->getTorrent();
     $data = \Rych\Bencode\Bencode::decode($data);
     foreach ($data as $itemKey => $item) {
         switch ($itemKey) {
             case 'announce-list':
                 foreach ($item as $announceItem) {
                     $announce = new Announce();
                     $announce->setAnnounce($announceItem[0]);
                     $torrent->addAnnounce($announce);
                 }
                 break;
             case 'comment':
                 $torrent->setComment($item);
                 break;
             case 'created by':
                 $torrent->setCreated_by($item);
                 break;
             case 'creation date':
                 $torrent->setCreation_date($item);
                 break;
             case 'encoding':
                 $torrent->setEncoding($item);
                 break;
             case 'rss':
                 $torrent->setRss($item);
                 break;
             case 'similar_torrents':
                 $torrent->setSimilar_torrents($item);
                 break;
             case 'url-list':
                 foreach ($item as $urlItem) {
                     $url = new Url();
                     $url->setUrl($urlItem);
                     $torrent->addUrl($url);
                 }
                 break;
             case 'website':
                 $torrent->setWebsite($item);
                 break;
             case 'info':
                 foreach ($item as $infoKeyItem => $itemInfo) {
                     switch ($infoKeyItem) {
                         case 'files':
                             foreach ($itemInfo as $fileItem) {
                                 $file = new File();
                                 $file->setLength($fileItem['length']);
                                 $file->setPath(implode('/', $fileItem['path']));
                                 $torrent->getInfo()->addFile($file);
                             }
                             break;
                         case 'name':
                             $torrent->getInfo()->setName($itemInfo);
                             break;
                         case 'piece length':
                             $torrent->getInfo()->setPiece_length($itemInfo);
                             break;
                         case 'pieces':
                             $torrent->getInfo()->setPieces($itemInfo);
                             break;
                         case 'private':
                             $torrent->getInfo()->setPrivate($itemInfo);
                             break;
                         case 'length':
                             $torrent->getInfo()->setPrivate($itemInfo);
                             break;
                         default:
                             $torrent->getInfo()->addOtherItem($infoKeyItem, $itemInfo);
                     }
                 }
                 break;
             default:
                 $torrent->addOtherItem($itemKey, $item);
         }
     }
 }