Completed
Pull Request — master (#178)
by Alex
14:30 queued 11:35
created

DiscoverCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 6
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the feed-io package.
4
 *
5
 * (c) Alexandre Debril <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace FeedIo\Command;
12
13
use FeedIo\Factory;
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
class DiscoverCommand extends Command
21
{
22
    protected function configure()
23
    {
24
        $this->setName('discover')
25
            ->setDescription('discovers feeds inside a web page')
26
            ->addArgument(
27
                'url',
28
                InputArgument::REQUIRED,
29
                'Please provide the URL'
30
            )
31
        ;
32
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $url = $input->getArgument('url');
37
        $output->writeln("<info>Discovering feeds from {$url}</info>");
38
        $feedIo = Factory::create()->getFeedIo();
39
        $feeds = $feedIo->discover($url);
40
41
        foreach ($feeds as $feed) {
42
            $output->writeln("<info>found : {$feed}</info>");
43
        }
44
    }
45
}
46