Completed
Push — master ( 54b8af...0621ed )
by Andrii
13:32
created

VersionController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A actionShow() 0 9 1
A actionUpdate() 0 4 1
A getComponent() 0 4 2
1
<?php
2
/**
3
 * Automation tool mixed with code generator for easier continuous development.
4
 *
5
 * @link      https://github.com/hiqdev/hidev
6
 * @package   hidev
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\console;
12
13
/**
14
 * Version management.
15
 */
16
class VersionController extends \hidev\base\Controller
17
{
18
    public $own;
19
20
    public $defaultAction = 'show';
21
22
    /**
23
     * Show current version.
24
     * @param string $release
25
     */
26
    public function actionShow($release = null)
27
    {
28
        $version = $this->getComponent();
29
        $version->load();
30
        $version->setRelease($release);
31
        $dir = dirname($version->getAbspath());
32
        echo $version->renderFile() . PHP_EOL;
33
        echo "(run from $dir)\n";
34
    }
35
36
    /**
37
     * Update version.
38
     * @param string $release
39
     */
40
    public function actionUpdate($release = null)
41
    {
42
        $this->getComponent()->update($release);
43
    }
44
45
    public function getComponent()
46
    {
47
        return $this->take(($this->own ? 'own.' : '') . 'version');
48
    }
49
}
50