1 | <?php |
||
17 | class FeedInspectCommand extends Command |
||
18 | { |
||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $data = []; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $values = []; |
||
28 | |||
29 | /** |
||
30 | * @inheritdoc |
||
31 | */ |
||
32 | protected function configure() |
||
33 | { |
||
34 | $this |
||
35 | ->setName('io:feed:inspect') |
||
36 | ->addArgument('url', InputArgument::REQUIRED, 'The url of the feed to inspect.') |
||
37 | ->addOption('node', null, InputOption::VALUE_REQUIRED, 'The item node name.') |
||
38 | ->addOption('limit', null, InputOption::VALUE_OPTIONAL, 'Number of distinct values per key to display', 20) |
||
39 | ->setDescription('Inspects a feed and displays information about it') |
||
40 | ; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @inheritdoc |
||
45 | */ |
||
46 | protected function interact(InputInterface $input, OutputInterface $output) |
||
47 | { |
||
48 | if (!$input->getOption('node')) { |
||
49 | $helper = new QuestionHelper(); |
||
50 | $question = new Question('Enter the name of the node that contains a property in this feed: '); |
||
51 | |||
52 | $node = $helper->ask($input, $output, $question); |
||
53 | $input->setOption('node', $node); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @inheritdoc |
||
59 | */ |
||
60 | protected function execute(InputInterface $input, OutputInterface $output) |
||
73 | |||
74 | /** |
||
75 | * @param string $url |
||
76 | * @param string $node |
||
77 | * |
||
78 | * @return Feed |
||
79 | */ |
||
80 | protected function getFeed($url, $node) |
||
88 | |||
89 | /** |
||
90 | * @param Feed $feed |
||
91 | */ |
||
92 | protected function inspect(Feed $feed) |
||
114 | |||
115 | /** |
||
116 | * @param OutputInterface $output |
||
117 | * @param int $limit |
||
118 | */ |
||
119 | protected function report(OutputInterface $output, $limit) |
||
174 | |||
175 | /** |
||
176 | * @param mixed $value |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | protected function arrayToString($value) |
||
192 | } |
||
193 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.