Completed
Push — master ( 05c35a...2edd45 )
by Alexis
06:51
created

StatusesHomeTimelineTestCommand::getTestContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6667
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace AlexisLefebvre\Bundle\AsyncTweetsBundle\Command;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Input\InputArgument;
7
8
class StatusesHomeTimelineTestCommand extends StatusesHomeTimelineCommand
9
{
10
    private $displayTable;
0 ignored issues
show
Comprehensibility introduced by Alexis Lefebvre
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by Alexis Lefebvre
The property $displayTable is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
11
    private $table;
0 ignored issues
show
Comprehensibility introduced by Alexis Lefebvre
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by Alexis Lefebvre
The property $table is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
12
    private $progress;
0 ignored issues
show
Comprehensibility introduced by Alexis Lefebvre
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by Alexis Lefebvre
The property $progress is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
13
    
14
    /** @see https://dev.twitter.com/rest/reference/get/statuses/home_timeline */
15
    private $parameters = array(
0 ignored issues
show
Comprehensibility introduced by Alexis Lefebvre
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by Alexis Lefebvre
The property $parameters is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
16
        'count' => 200,
17
        'exclude_replies' => true
18
    );
19
    
20 7
    protected function configure()
21
    {
22 7
        parent::configure();
23
        
24 7
        $this
25 7
            ->setName('statuses:hometimelinetest')
26 7
            ->setDescription('Fetch home timeline test')
27 7
            ->addArgument(
28 7
                'test',
29 7
                InputArgument::OPTIONAL,
30
                'Return data for tests'
31 7
            )    
32
        ;
33 7
    }
34
    
35
    /**
36
     * Read tweet(s) from a JSON file
37
     * 
38
     * @param string $filename
39
     * @return array
40
     */
41 3
    protected function getTestContent($filename)
42
    {
43
        /** @see https://insight.sensiolabs.com/what-we-analyse/symfony.dependency_injection.use_dir_file_constant */
44 3
        return(json_decode(file_get_contents(
45 3
            $this->container->get('kernel')->locateResource(
46
                '@AsyncTweetsBundle/Tests/Command/data/'.$filename
47 3
            )
48 3
        )));
49
    }
50
    
51
    /**
52
     * @param InputInterface $input
53
     */
54 7
    protected function getContent(InputInterface $input)
55
    {
56 7
        switch($input->getArgument('test')) {
57 7
            case 'json':
58 2
                return($this->getTestContent(
59 2
                    'tweets_32_bits.json'));
60 5
            case 'json_with_retweet':
61 1
                return($this->getTestContent(
62 1
                    'tweet_with_retweet.json'));
63 4
            case 'not_array':
64
                // Return null instead of JSON
65 1
                return(null);
66 3
            case 'empty_array':
67
                // Return an empty array instead of JSON
68 2
                return(array());
69 1
            default:
70
                // Normal behaviour
71 1
                return(parent::getContent($input)); 
72 1
        }
73
    }
74
}
75