PageRankCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 9
rs 10
1
<?php
2
3
namespace PiedWeb\SeoPocketCrawler\Command;
4
5
use PiedWeb\SeoPocketCrawler\LinksVisualizer;
6
use PiedWeb\SeoPocketCrawler\SimplePageRankCalculator;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class PageRankCommand extends Command
13
{
14
    protected static $defaultName = 'crawler:pagerank';
15
16
    protected $id;
17
18
    protected function configure()
19
    {
20
        $this->setDescription('Add internal page rank to index.csv');
21
22
        $this
23
            ->addArgument(
24
                'id',
25
                InputArgument::REQUIRED,
26
                'id from a previous crawl'
27
                .PHP_EOL.'You can use `last` to calcul page rank from the last crawl.'
28
            )
29
        ;
30
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $pr = new SimplePageRankCalculator((string) $input->getArgument('id'));
35
36
        echo $pr->record().PHP_EOL;
37
38
        new LinksVisualizer((string) $input->getArgument('id'));
39
40
        return 0;
41
    }
42
}
43