Replace arrays with Tweet model
This commit is contained in:
parent
482df07a6d
commit
c18fcd0e2e
5 changed files with 34 additions and 15 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\Tweet;
|
||||
use App\Service\TweetFetcher;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
@ -39,12 +40,12 @@ class FetchTweetsCommand extends Command
|
|||
|
||||
$io->table(
|
||||
['Tweet', 'Author', 'Created', 'ID'],
|
||||
$this->tweetFetcher->getTweets()->map(function (array $tweet) {
|
||||
$this->tweetFetcher->getTweets()->map(function (Tweet $tweet) {
|
||||
return [
|
||||
$tweet['text'],
|
||||
$tweet['author'],
|
||||
$tweet['created'],
|
||||
$tweet['id'],
|
||||
$tweet->getText(),
|
||||
$tweet->getAuthor(),
|
||||
$tweet->getCreated(),
|
||||
$tweet->getId(),
|
||||
];
|
||||
})->all()
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\Tweet;
|
||||
use App\Service\Retweeter;
|
||||
use App\Service\TweetFetcher;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
@ -36,7 +37,7 @@ class RetweetTweetsCommand extends Command
|
|||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->tweetFetcher->getTweets()->each(function (array $tweet) {
|
||||
$this->tweetFetcher->getTweets()->each(function (Tweet $tweet) {
|
||||
$this->retweeter->retweet($tweet);
|
||||
});
|
||||
}
|
||||
|
|
Reference in a new issue