Skip to content

Commit ca96174

Browse files
author
itismadness
committed
add getCreationDate method
1 parent 5ce1e6c commit ca96174

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/BencodeTorrent.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ public function makePrivate(): bool
209209
* 'official' flag (no accepted BEP on it), but it has become the defacto standard with more
210210
* clients supporting it natively. Returns a boolean on whether or not the source was changed
211211
* so that an appropriate screen can be shown to the user.
212-
*
213-
* @param string $source
214-
*
215-
* @return bool true if the source was set/changed, false if no change
216212
*/
217213
public function setSource(string $source): bool
218214
{
@@ -228,19 +224,29 @@ public function setSource(string $source): bool
228224
return true;
229225
}
230226

227+
/**
228+
* Get the source flag if one has been set
229+
*/
231230
public function getSource(): ?string
232231
{
233232
$this->hasData();
234233
return $this->data['info']['source'] ?? null;
235234
}
236235

236+
/**
237+
* Get the creation date for torrent if one has been set
238+
*/
239+
public function getCreationDate(): ?int
240+
{
241+
$this->hasData();
242+
return $this->data['creation date'] ?? null;
243+
}
244+
237245
/**
238246
* Function to allow you set any number of keys and values in the data dictionary. You can
239247
* set the value in a dictionary by concatenating the keys into a string with a period
240248
* separator (ex: info.name will set name field in the info dictionary) so that the rest
241249
* of the dictionary is unaffected.
242-
*
243-
* @param array $array
244250
*/
245251
public function setValue(array $array): void
246252
{

tests/BencodeTorrentTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public function testLoadTorrent(): void
144144
]
145145
];
146146
$this->assertEquals($file_list, $bencode->getFileList());
147+
$this->assertSame(1425699508, $bencode->getCreationDate());
147148
}
148149

149150
public function testSetData(): void

0 commit comments

Comments
 (0)