Completed
Push — master ( 8d38b3...065629 )
by Andrii
02:12
created

AbstractRenderer::render()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 1
ccs 0
cts 0
cp 0
nc 1
1
<?php
2
/**
3
 * Changelog keeper
4
 *
5
 * @link      https://github.com/hiqdev/chkipper
6
 * @package   chkipper
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\chkipper\lib\renderers;
12
13
use hiqdev\chkipper\lib\ConfigInterface;
14
use hiqdev\chkipper\lib\History;
15
use hiqdev\chkipper\lib\modifiers\Normalization;
16
17
/**
18
 * Abstract history renderer.
19
 *
20
 * @author Andrii Vasyliev <[email protected]>
21
 */
22
abstract class AbstractRenderer
23
{
24
    /**
25
     * @var ConfigInterface config object
26
     */
27
    protected $_config;
28
29
    protected $normalization = Normalization::class;
30
31 2
    public function __construct(ConfigInterface $config)
32
    {
33 2
        $this->_config = $config;
34 2
    }
35
36 1
    public function getConfig()
37
    {
38 1
        return $this->_config;
39
    }
40
41 2
    public function setHistory($value)
42
    {
43 2
        $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...
44 2
        if (!empty($this->normalization)) {
45 2
            Normalization::create($this->normalization)->run($this->_history);
46 2
        }
47 2
    }
48
49 2
    public function getHistory()
50
    {
51 2
        return $this->_history;
52
    }
53
54
    /**
55
     * Renders history to string.
56
     * @param History $history
57
     * @return string
58
     */
59
    abstract public function render(History $history);
60
}
61