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

VersionController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 39
ccs 0
cts 23
cp 0
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getComponent() 0 4 2
A actionShow() 0 11 1
A actionUpdate() 0 7 1
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