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

Native::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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