Completed
Push — master ( b4af2d...85fa4e )
by Andrii
02:31
created

BumpController::actionParse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 9.6666
cc 2
eloc 6
nc 2
nop 1
crap 6
1
<?php
2
3
/*
4
 * Changelog keeper
5
 *
6
 * @link      https://github.com/hiqdev/chkipper
7
 * @package   chkipper
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hiqdev\chkipper\console;
13
14
use hiqdev\chkipper\history\GitLogParser;
15
use hiqdev\chkipper\history\MarkdownParser;
16
use hiqdev\chkipper\history\MarkdownRenderer;
17
use Exception;
18
use Yii;
19
20
/**
21
 * Bump Controller.
22
 *
23
 * @author Andrii Vasyliev <[email protected]>
24
 */
25
class BumpController extends \yii\console\Controller
26
{
27
    public function actionIndex()
28
    {
29
        $historyFile = Yii::$app->config->historyFile;
30
        $parser = new MarkdownParser();
31
        $history = $parser->parsePath($historyFile);
32
        $gitlog = new GitLogParser();
33
        $gitlog->parseGitLog();
34
        $history->merge($gitlog->getHistory());
35
        $renderer = new MarkdownRenderer();
36
        file_put_contents($historyFile,  $renderer->render($history));
37
    }
38
39
    public function actionParse($path)
40
    {
41
        if (!file_exists($path)) {
42
            throw new Exception('wrong path: ' . $path);
43
        }
44
        $parser = new MarkdownParser();
45
        $history = $parser->parsePath($path);
46
        var_dump($history->getTags());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($history->getTags()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
47
    }
48
}
49