From e35a8553197a15cfa0394e9c999f419503124c3a Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Fri, 22 Jun 2018 18:21:10 +0300 Subject: [PATCH] Entity type-hinting and phpDoc cleanup. --- src/Entity/File.php | 8 +++++--- src/Entity/Torrent.php | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Entity/File.php b/src/Entity/File.php index bdf1091..452558c 100644 --- a/src/Entity/File.php +++ b/src/Entity/File.php @@ -21,7 +21,7 @@ class File private $id; /** - * @var int + * @var Torrent * * @ORM\ManyToOne(targetEntity="App\Entity\Torrent", inversedBy="files") * @ORM\JoinColumn(name="torrent_id") @@ -29,7 +29,7 @@ class File private $torrent; /** - * @var int + * @var int File size in bytes * * @ORM\Column(name="size", type="integer", nullable=false) */ @@ -47,16 +47,18 @@ class File return $this->id; } - public function getTorrent(): int + public function getTorrent(): Torrent { return $this->torrent; } + /** Returns file size in bytes */ public function getSize(): int { return $this->size; } + /** Returns file path relative to the torrent root directory */ public function getPath(): string { return $this->path; diff --git a/src/Entity/Torrent.php b/src/Entity/Torrent.php index 7d58d7b..63650c5 100644 --- a/src/Entity/Torrent.php +++ b/src/Entity/Torrent.php @@ -23,7 +23,7 @@ class Torrent private $id; /** - * @var resource + * @var resource Resource pointing to info-hash BLOB * * @ORM\Column(name="info_hash", type="blob", nullable=false) */ @@ -35,21 +35,21 @@ class Torrent private $infoHashHexCache; /** - * @var string + * @var string Torrent name * * @ORM\Column(name="name", type="text", nullable=false) */ private $name; /** - * @var int + * @var int Torrent files total size in bytes * * @ORM\Column(name="total_size", type="integer", nullable=false) */ private $totalSize; /** - * @var int + * @var int Torrent discovery timestamp * * @ORM\Column(name="discovered_on", type="integer", nullable=false) */ @@ -67,11 +67,17 @@ class Torrent return $this->id; } + /** + * Returns torrent info hash BLOB resource + * + * @return resource + */ public function getInfoHash() { return $this->infoHash; } + /** Returns torrent info hash as HEX string */ public function getInfoHashAsHex(): string { if (null === $this->infoHashHexCache) { @@ -87,11 +93,13 @@ class Torrent return $this->name; } + /** Returns torrent files total size in bytes */ public function getTotalSize(): int { return $this->totalSize; } + /** Returns torrent discovery timestamp */ public function getDiscoveredOn(): int { return $this->discoveredOn;