UpdateCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 44
ccs 0
cts 20
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 6 1
A execute() 0 12 2
A verifyInstalled() 0 7 1
1
<?php
2
/**
3
 * PHPCI - Continuous Integration for PHP.
4
 *
5
 * @copyright    Copyright 2014, Block 8 Limited.
6
 * @license      https://github.com/Block8/PHPCI/blob/master/LICENSE.md
7
 *
8
 * @link         https://www.phptesting.org/
9
 */
10
11
namespace PHPCI\Command;
12
13
use b8\Config;
14
use Monolog\Logger;
15
use PHPCI\Helper\Lang;
16
use Symfony\Component\Console\Command\Command;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
/**
21
 * Generate console command - Reads the database and generates models and stores.
22
 *
23
 * @author       Dan Cryer <[email protected]>
24
 */
25
class UpdateCommand extends Command
26
{
27
    /**
28
     * @var \Monolog\Logger
29
     */
30
    protected $logger;
31
32
    public function __construct(Logger $logger, $name = null)
33
    {
34
        parent::__construct($name);
35
        $this->logger = $logger;
36
    }
37
38
    protected function configure()
39
    {
40
        $this
41
            ->setName('phpci:update')
42
            ->setDescription(Lang::get('update_phpci'));
43
    }
44
45
    /**
46
     * Generates Model and Store classes by reading database meta data.
47
     */
48
    protected function execute(InputInterface $input, OutputInterface $output)
49
    {
50
        if (!$this->verifyInstalled($output)) {
51
            return;
52
        }
53
54
        $output->write(Lang::get('updating_phpci'));
55
56
        shell_exec(PHPCI_DIR.'vendor/bin/phinx migrate -c "'.PHPCI_DIR.'phinx.php"');
57
58
        $output->writeln('<info>'.Lang::get('ok').'</info>');
59
    }
60
61
    protected function verifyInstalled(OutputInterface $output)
0 ignored issues
show
Unused Code introduced by
The parameter $output is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
    {
63
        $config = Config::getInstance();
64
        $phpciUrl = $config->get('phpci.url');
65
66
        return !empty($phpciUrl);
67
    }
68
}
69