Completed
Push — master ( 70ef2d...0e5aaa )
by Alex
16s queued 10s
created

DiscoverCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 26
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A execute() 0 11 2
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