add getCreationDate method

This commit is contained in:
itismadness
2020-10-03 20:31:03 +00:00
parent 5ce1e6c6cc
commit ca9617422a
2 changed files with 13 additions and 6 deletions
+12 -6
View File
@@ -209,10 +209,6 @@ class BencodeTorrent extends Bencode
* 'official' flag (no accepted BEP on it), but it has become the defacto standard with more
* clients supporting it natively. Returns a boolean on whether or not the source was changed
* so that an appropriate screen can be shown to the user.
*
* @param string $source
*
* @return bool true if the source was set/changed, false if no change
*/
public function setSource(string $source): bool
{
@@ -228,19 +224,29 @@ class BencodeTorrent extends Bencode
return true;
}
/**
* Get the source flag if one has been set
*/
public function getSource(): ?string
{
$this->hasData();
return $this->data['info']['source'] ?? null;
}
/**
* Get the creation date for torrent if one has been set
*/
public function getCreationDate(): ?int
{
$this->hasData();
return $this->data['creation date'] ?? null;
}
/**
* Function to allow you set any number of keys and values in the data dictionary. You can
* set the value in a dictionary by concatenating the keys into a string with a period
* separator (ex: info.name will set name field in the info dictionary) so that the rest
* of the dictionary is unaffected.
*
* @param array $array
*/
public function setValue(array $array): void
{
+1
View File
@@ -144,6 +144,7 @@ class BencodeTorrentTest extends \PHPUnit\Framework\TestCase
]
];
$this->assertEquals($file_list, $bencode->getFileList());
$this->assertSame(1425699508, $bencode->getCreationDate());
}
public function testSetData(): void