VersionController::actionShow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 8
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
b 0
f 0
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-2018, 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