Completed
Push — master ( 808823...246322 )
by Andrii
02:33
created

AbstractRenderer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 31.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 41
ccs 5
cts 16
cp 0.3125
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setHistory() 0 4 1
A getHistory() 0 4 1
render() 0 1 ?
B skipCommit() 0 25 4
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\history;
13
14
/**
15
 * Abstract history renderer.
16
 *
17
 * @author Andrii Vasyliev <[email protected]>
18
 */
19
abstract class AbstractRenderer
20
{
21 1
    public function setHistory($value)
22
    {
23 1
        $this->_history = $value;
0 ignored issues
show
Bug introduced by
The property _history does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24 1
    }
25
26 1
    public function getHistory()
27
    {
28 1
        return $this->_history;
29
    }
30
31
    abstract public function render(History $history);
32
33
    public static function skipCommit(Commit $commit)
34
    {
35
        $comment = $commit['comment'];
36
37
        static $equals = [
38
            ''      => 1,
39
            'minor' => 1,
40
        ];
41
        if ($equals[$comment]) {
42
            return true;
43
        }
44
45
        static $starts = [
46
            'version bump',
47
            'bumped version',
48
            "merge branch 'master'",
49
        ];
50
        foreach ($starts as $start) {
51
            if (strtolower(substr($comment, 0, strlen($start))) === $start) {
52
                return true;
53
            }
54
        }
55
56
        return false;
57
    }
58
59
}
60