Skip to content

Commit

Permalink
Only support DateTimeInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
dwightwatson committed Oct 4, 2019
1 parent 9123382 commit efec114
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -125,7 +125,7 @@ public function toFacebookPoster($notifiable) {
```

### Publish Facebook scheduled post
It is also possible to publish a scheduled post. You just have to pass a UNIX timestamp to the `scheduledFor` method.
It is also possible to publish a scheduled post. You just need to pass an instance of `DateTimeInterface` in - so any `DateTime` or Carbon instance will work.

```php
public function toFacebookPoster($notifiable) {
Expand Down
10 changes: 3 additions & 7 deletions src/FacebookPosterPost.php
Expand Up @@ -116,17 +116,13 @@ public function withVideo($path, $title = null, $description = null, $endpoint =
/**
* Schedule the post for a date in the future.
*
* @param \DateTimeInterface|int $timestamp
* @param \DateTimeInterface $timestamp
* @return $this
*/
public function scheduledFor($timestamp)
public function scheduledFor(DateTimeInterface $timestamp)
{
$timestamp = $timestamp instanceof DateTimeInterface
? $timestamp->getTimestamp()
: $timestamp;

$this->params['published'] = false;
$this->params['scheduled_publish_time'] = $timestamp;
$this->params['scheduled_publish_time'] = $timestamp->getTimestamp();

return $this;
}
Expand Down
16 changes: 0 additions & 16 deletions tests/FacebookPosterPostTest.php
Expand Up @@ -13,22 +13,6 @@ public function it_can_be_scheduled()
{
$post = new FacebookPosterPost('message');

$post->scheduledFor(1234);

$result = $post->getBody();

$this->assertEquals([
'message' => 'message',
'published' => false,
'scheduled_publish_time' => 1234,
], $result);
}

/** @test */
public function it_can_be_scheduled_with_datetime()
{
$post = new FacebookPosterPost('message');

$post->scheduledFor(new DateTime('2000-01-01'));

$result = $post->getBody();
Expand Down

0 comments on commit efec114

Please sign in to comment.