seria/src/Torrents/TorrentInfo.php

83 lines
2 KiB
PHP

<?php
namespace Seria\Torrents;
use Index\Data\IDbResult;
readonly class TorrentInfo {
private string $id;
private ?string $userId;
private string $infoHash;
private int $active;
private string $name;
private int $created;
private ?int $approved;
private int $pieceLength;
private int $private;
private string $comment;
public function __construct(IDbResult $result) {
$this->id = $result->getString(0);
$this->userId = $result->isNull(1) ? null : $result->getString(1);
$this->infoHash = $result->getString(2);
$this->active = $result->getInteger(3); // i don't think anything uses this field
$this->name = $result->getString(4);
$this->created = $result->getInteger(5);
$this->approved = $result->isNull(6) ? null : $result->getInteger(6);
$this->pieceLength = $result->getInteger(7);
$this->private = $result->getInteger(8);
$this->comment = $result->getString(9);
}
public function getId(): string {
return $this->id;
}
public function hasUser(): bool {
return $this->userId !== null;
}
public function getUserId(): ?string {
return $this->userId;
}
public function getHash(): string {
return $this->infoHash;
}
public function isActive(): bool {
return $this->active !== 0;
}
public function getName(): string {
return $this->name;
}
public function getCreatedTime(): int {
return $this->created;
}
public function getApprovedTime(): ?int {
return $this->approved;
}
public function isApproved(): bool {
return $this->approved !== null;
}
public function getPieceLength(): int {
return $this->pieceLength;
}
public function isPrivate(): bool {
return $this->private !== 0;
}
public function hasComment(): bool {
return $this->comment !== '';
}
public function getComment(): string {
return $this->comment;
}
}