Updater   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A runUpdateCommand() 0 6 1
A runCommand() 0 9 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Updater Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\UpdaterBundle\Manager;
16
17
use Symfony\Component\Console\Input\ArrayInput;
18
use Symfony\Component\Console\Output\NullOutput;
19
use Updater\Console\Application;
20
21
/**
22
 * Updater wrapper.
23
 */
24
class Updater
25
{
26
    const UPDATE_COMMAND = 'update';
27
28
    /**
29
     * Runs update command with given parameters.
30
     *
31
     * @param array $parameters Command parameters
32
     *
33
     * @return string Command output
34
     */
35
    public static function runUpdateCommand(array $parameters = array())
36
    {
37
        $parameters['command'] = self::UPDATE_COMMAND;
38
39
        return self::runCommand($parameters);
40
    }
41
42
    private static function runCommand(array $parameters = array())
43
    {
44
        $input = new ArrayInput($parameters);
45
        $output = new NullOutput();
46
        $app = new Application();
47
        $app->setAutoExit(false);
48
49
        return $app->run($input, $output);
50
    }
51
}
52