Completed
Push — master ( a0f8dd...4bb285 )
by Andrii
13:40
created

VersionController::actionMake()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 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\controllers;
12
13
/**
14
 * Version management.
15
 */
16
class VersionController extends \hidev\base\Controller
17
{
18
    public $own;
19
20
    public function getComponent()
21
    {
22
        return $this->take(($own ? 'own.' : '') . 'version');
0 ignored issues
show
Bug introduced by
The variable $own does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
23
    }
24
25
    public $defaultAction = 'show';
26
27
    /**
28
     * Show current version.
29
     * @param string $release 
30
     */
31
    public function actionShow($release = null)
32
    {
33
        $version = $this->getComponent();
34
        $version->load();
35
        $version->setRelease($release);
36
        $dir    = dirname($version->getAbspath());
37
        $pretty = $version->pretty();
38
        $name   = $this->take('package')->name;
39
        echo "$name $pretty\n";
40
        echo "(run from $dir)\n";
41
    }
42
43
    /**
44
     * Update version.
45
     * @param string $release 
46
     */
47
    public function actionUpdate($release = null)
48
    {
49
        $version = $this->getComponent();
50
        $version->load();
51
        $version->setRelease($release);
52
        $version->save();
53
    }
54
}
55