Skip to content

Commit

Permalink
add getCreationDate method
Browse files Browse the repository at this point in the history
  • Loading branch information
itismadness committed Oct 3, 2020
1 parent 5ce1e6c commit ca96174
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/BencodeTorrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@ public function makePrivate(): bool
* '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
{
Expand All @@ -228,19 +224,29 @@ public function setSource(string $source): bool
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
{
Expand Down
1 change: 1 addition & 0 deletions tests/BencodeTorrentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public function testLoadTorrent(): void
]
];
$this->assertEquals($file_list, $bencode->getFileList());
$this->assertSame(1425699508, $bencode->getCreationDate());
}

public function testSetData(): void
Expand Down

0 comments on commit ca96174

Please sign in to comment.