Completed
Push — master ( 256116...bf8903 )
by personal
04:47
created

SelfUpdateCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 10 1
A execute() 0 11 1
1
<?php
2
3
/*
4
 * (c) Jean-François Lépine <https://twitter.com/Halleck45>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Hal\Application\Command;
11
use Hal\Application\Command\Job\QueueFactory;
12
use Hal\Application\Config\ConfigFactory;
13
use Hal\Component\Bounds\Bounds;
14
use Hal\Component\Evaluation\Evaluator;
15
use Hal\Component\File\Finder;
16
use Hal\Component\Phar\Updater;
17
use Symfony\Component\Console\Command\Command;
18
use Symfony\Component\Console\Input\InputArgument;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Input\InputOption;
21
use Symfony\Component\Console\Output\OutputInterface;
22
23
/**
24
 * Command for updating phar
25
 *
26
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
27
 */
28
class SelfUpdateCommand extends Command
29
{
30
    /**
31
     * @inheritdoc
32
     */
33
    protected function configure()
34
    {
35
        $this
36
                ->setName('self-update')
37
                ->addArgument(
38
                    'version', InputArgument::OPTIONAL, 'Required version. Ex: "v1.6.2" (default: "latest")', 'latest'
39
                )
40
                ->setDescription('Updates phar archive')
41
        ;
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $output->writeln(sprintf('<info>Installing %s version...</info>', $input->getArgument('version')));
50
51
        $updater = new Updater($output);
52
        $version = $updater->updates($input->getArgument('version'));
53
54
        $output->writeln('');
55
        $output->writeln(sprintf('<info>Done. PhpMetrics updated to %s</info>', $version));
56
        return 0;
57
    }
58
59
}
60