diff --git a/src/FilterRule/StripHtml.php b/src/FilterRule/StripHtml.php index 85efc14..6ebd99b 100644 --- a/src/FilterRule/StripHtml.php +++ b/src/FilterRule/StripHtml.php @@ -40,6 +40,10 @@ public function __construct($excludeTags = null) */ public function filter($value) { + if ($value === null) { + return $value; + } + return strip_tags($value, $this->excludeTags); } } diff --git a/src/FilterRule/Trim.php b/src/FilterRule/Trim.php index 8c20fc3..36dcc1e 100644 --- a/src/FilterRule/Trim.php +++ b/src/FilterRule/Trim.php @@ -40,6 +40,10 @@ public function __construct($characters = null) */ public function filter($value) { + if ($value === null) { + return $value; + } + if ($this->characters === null) { return trim($value); } diff --git a/tests/FilterRule/StripHtmlTest.php b/tests/FilterRule/StripHtmlTest.php index 8a7e62a..904097f 100644 --- a/tests/FilterRule/StripHtmlTest.php +++ b/tests/FilterRule/StripHtmlTest.php @@ -32,7 +32,7 @@ public function testStripHtmlFilterRule($value, $excludeTags, $filteredValue) 'test' => $value ]); - $this->assertEquals($filteredValue, $result['test']); + $this->assertSame($filteredValue, $result['test']); } /** @@ -44,6 +44,7 @@ public function getStripHtmlResults() ['', '', ''], ['

text

', null, 'text'], ['

text

', '

', '

text

'], + [null, null, null], ]; } } diff --git a/tests/FilterRule/TrimTest.php b/tests/FilterRule/TrimTest.php index eaedf07..ab6760f 100644 --- a/tests/FilterRule/TrimTest.php +++ b/tests/FilterRule/TrimTest.php @@ -36,7 +36,7 @@ public function testTrimFilterRule($value, $filteredValue, $characters) 'test' => $value ]); - $this->assertEquals($filteredValue, $result['test']); + $this->assertSame($filteredValue, $result['test']); } /** @@ -54,6 +54,7 @@ public function getTrimResults() [' abc ', 'abc', null], [' !~! ', '!~!', null], [' tabtab ', ' tabtab ', "\t"], + [null, null, null], ]; } }