Passed
Pull Request — master (#65)
by Alexis
02:08
created

StatusesShowCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 37
ccs 6
cts 18
cp 0.3333
rs 10
c 0
b 0
f 0

2 Methods

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