Add RetweetTweetsCommand.php

This commit is contained in:
Oliver Davies 2019-01-10 23:04:07 +00:00
parent 91af0ef7f8
commit 2ff65f7334

View file

@ -0,0 +1,38 @@
<?php
namespace App\Command;
use App\Service\TweetFetcher;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class RetweetTweetsCommand extends Command
{
protected static $defaultName = 'app:retweet-tweets';
private $tweetFetcher;
public function __construct(TweetFetcher $tweetFetcher)
{
parent::__construct();
$this->tweetFetcher = $tweetFetcher;
}
protected function configure()
{
$this
->setDescription('Add a short description for your command')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->tweetFetcher->getTweets()->each(function (array $tweet) {
$this->retweeter->retweet();
});
}
}