Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 15
StatusesShowCommand
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 15
 configure
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 5
 execute
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 10
1<?php
2
3namespace AlexisLefebvre\Bundle\AsyncTweetsBundle\Command;
4
5use Abraham\TwitterOAuth\TwitterOAuth;
6use Symfony\Component\Console\Input\InputArgument;
7use Symfony\Component\Console\Input\InputInterface;
8use Symfony\Component\Console\Output\OutputInterface;
9
10class StatusesShowCommand extends BaseCommand
11{
12    protected function configure(): void
13    {
14        parent::configure();
15
16        $this
17            ->setName('statuses:show')
18            ->setDescription('Show one tweet (for debugging)')
19            ->addArgument('tweet_id', InputArgument::REQUIRED, 'Tweet ID');
20    }
21
22    protected function execute(InputInterface $input, OutputInterface $output): int
23    {
24        /** @var int|null $tweet_id */
25        $tweet_id = $input->getArgument('tweet_id');
26
27        $connection = new TwitterOAuth(
28            (string) $this->container->getParameter('twitter_consumer_key'),
29            (string) $this->container->getParameter('twitter_consumer_secret'),
30            (string) $this->container->getParameter('twitter_token'),
31            (string) $this->container->getParameter('twitter_token_secret')
32        );
33
34        /** @var string $json */
35        $json = json_encode($connection->get(sprintf(
36            'statuses/show/%d',
37            $tweet_id
38        )));
39
40        $output->writeln($json);
41
42        return 0;
43    }
44}