Skip to content

Commit 816d4cb

Browse files
committed
deny Change to accept arrays of strings
1 parent c91dee3 commit 816d4cb

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/Change.php

+10-13
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,36 @@
44

55
class Change
66
{
7+
/**
8+
* @var mixed
9+
*/
710
private $oldValue;
811

12+
/**
13+
* @var mixed
14+
*/
915
private $newValue;
1016

1117
/**
12-
* @param array|string $oldValue
13-
* @param array|string $newValue
18+
* @param mixed $oldValue
19+
* @param mixed $newValue
1420
*/
1521
public function __construct($oldValue, $newValue)
1622
{
17-
// old value
18-
if (!is_array($oldValue)) {
19-
$oldValue = (string)$oldValue;
20-
}
2123
$this->oldValue = $oldValue;
22-
23-
// new value
24-
if (!is_array($newValue)) {
25-
$newValue = (string)$newValue;
26-
}
2724
$this->newValue = $newValue;
2825
}
2926

3027
/**
31-
* @return array|string
28+
* @return mixed
3229
*/
3330
public function getOldValue()
3431
{
3532
return $this->oldValue;
3633
}
3734

3835
/**
39-
* @return array|string
36+
* @return mixed
4037
*/
4138
public function getNewValue()
4239
{

src/Renderer.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ public function setFormat($format)
107107
public function render(Change $change)
108108
{
109109
// get diff
110-
$diff = $this->differ->diffToArray($change->getOldValue(), $change->getNewValue());
110+
$diff = $this->differ->diffToArray(
111+
(string)$change->getOldValue(),
112+
(string)$change->getNewValue()
113+
);
111114

112115
// render diff
113116
foreach ($diff as &$line) {

tests/RendererTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function renderChangeDataProvider()
8080
* @param $newValue
8181
* @param array|null $renderOptions
8282
*/
83-
public function testRender_ChanageValueStringType(
83+
public function testRender_ChangeValueHasStringType(
8484
$expectedDiff,
8585
$oldValue,
8686
$newValue,

0 commit comments

Comments
 (0)