Display tweets in a table

This commit is contained in:
Oliver Davies 2019-01-10 22:57:07 +00:00
parent a02713b644
commit 91af0ef7f8
2 changed files with 12 additions and 2 deletions

View file

@ -37,6 +37,16 @@ class FetchTweetsCommand extends Command
{
$io = new SymfonyStyle($input, $output);
dump($this->tweetFetcher->getTweets());
$io->table(
['Tweet', 'Author', 'Created', 'ID'],
$this->tweetFetcher->getTweets()->map(function (array $tweet) {
return [
$tweet['text'],
$tweet['author'],
$tweet['created'],
$tweet['id'],
];
})->all()
);
}
}

View file

@ -57,7 +57,7 @@ class TweetFetcher
return collect($response->get('statuses'))
->map(function (\stdClass $tweet) {
return (object) [
return [
'id' => $tweet->id,
'created' => strtotime($tweet->created_at),
'text' => $tweet->text,