seria/src/Torrents/TorrentFileInfo.php

43 lines
1,003 B
PHP

<?php
namespace Seria\Torrents;
use Index\Data\IDbResult;
use Index\Serialisation\IBencodeSerialisable;
readonly class TorrentFileInfo implements IBencodeSerialisable {
private string $id;
private string $torrentId;
private int $length;
private string $path;
public function __construct(IDbResult $result) {
$this->id = $result->getString(0);
$this->torrentId = $result->getString(1);
$this->length = $result->getInteger(2);
$this->path = $result->getString(3);
}
public function getId(): string {
return $this->id;
}
public function getTorrentId(): string {
return $this->torrentId;
}
public function getLength(): int {
return $this->length;
}
public function getPath(): string {
return $this->path;
}
public function bencodeSerialise(): mixed {
return [
'length' => $this->length,
'path' => explode('/', $this->path),
];
}
}