From 2ff65f7334fb9f0733d650b7dfe439be40dd821b Mon Sep 17 00:00:00 2001 From: Oliver Davies <oliver@oliverdavies.uk> Date: Thu, 10 Jan 2019 23:04:07 +0000 Subject: [PATCH] Add RetweetTweetsCommand.php --- src/Command/RetweetTweetsCommand.php | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Command/RetweetTweetsCommand.php diff --git a/src/Command/RetweetTweetsCommand.php b/src/Command/RetweetTweetsCommand.php new file mode 100644 index 0000000..f0121d4 --- /dev/null +++ b/src/Command/RetweetTweetsCommand.php @@ -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(); + }); + } +}