Passed
Push — main ( b13b1c...30676d )
by Emlyn
12:24
created

Native   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 42
ccs 11
cts 11
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setContent() 0 3 1
A getContent() 0 11 2
1
<?php
2
/**
3
 * @category Library
4
 * @license MIT http://opensource.org/licenses/MIT
5
 * @link https://github.com/emlynwest/changelog
6
 */
7
8
namespace ChangeLog\IO;
9
10
use ChangeLog\AbstractIO;
11
12
/**
13
 * Allows a native string to be used as a change log source
14
 */
15
class Native extends AbstractIO
16
{
17
18
	/**
19
	 * @var string|string[]
20
	 */
21
	protected $content;
22
23
	protected $configDefaults = [
24
		'line_separator' => "\n",
25
	];
26
27
	/**
28
	 * @param string $content
29
	 */
30 2
	public function __construct($content = '')
31
	{
32 2
		$this->setContent($content);
33
	}
34
35
	/**
36
	 * {@inheritdoc}
37
	 */
38 2
	public function setContent($content)
39
	{
40 2
		$this->content = $content;
41
	}
42
43
	/**
44
	 * {@inheritdoc}
45
	 */
46 1
	public function getContent()
47
	{
48 1
		if (is_string($this->content))
49
		{
50 1
			return explode(
51 1
				$this->getConfig('line_separator'),
0 ignored issues
show
Bug introduced by
It seems like $this->getConfig('line_separator') can also be of type array; however, parameter $separator of explode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

51
				/** @scrutinizer ignore-type */ $this->getConfig('line_separator'),
Loading history...
52 1
				$this->content
53 1
			);
54
		}
55
56 1
		return $this->content;
57
	}
58
}
59