Completed
Push — master ( 83bd2d...9517e2 )
by Arne
03:10
created

InfoCommand::execute()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 2
1
<?php
2
3
namespace Archivr\Cli\Command;
4
5
use Archivr\ArchivR;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class InfoCommand extends AbstractCommand
11
{
12
    protected function configure()
13
    {
14
        $this->setName('info');
15
        $this->setDescription('Displays information about a vault and its local representation.');
16
        $this->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Configuration file to use.');
17
    }
18
19
    protected function execute(InputInterface $input, OutputInterface $output)
20
    {
21
        $configuration = $this->getConfiguration($input);
22
23
        if ($configuration === null)
24
        {
25
            $output->writeln(sprintf('This does not seem to be an archive!'));
26
27
            return;
28
        }
29
30
        $archivr = new ArchivR($configuration);
31
32
        $operationCollection = $archivr->buildOperationCollection();
33
34
        if (count($operationCollection))
35
        {
36
            $output->writeln(sprintf('<info>There are %d outstanding operations!</info>', count($operationCollection)));
37
        }
38
        else
39
        {
40
            $output->writeln('<info>Everything is up to date!</info>');
41
        }
42
    }
43
}
44