Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Allow null value #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ public static function create(array $config): SanitizerInterface
return SanitizerBuilder::createDefault()->build($config);
}

public function sanitize(string $html): string
public function sanitize(?string $html = null): ?string
{
if(!$html)
{
return null;
}

$sanitized = $this->doSanitize($html);

if ($this->logger) {
Expand Down
2 changes: 1 addition & 1 deletion src/SanitizerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
*/
interface SanitizerInterface
{
public function sanitize(string $html): string;
public function sanitize(?string $html = null): ?string;
}
8 changes: 8 additions & 0 deletions tests/SimpleSanitizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public function createSanitizer(): SanitizerInterface
public function provideFixtures(): array
{
return array_merge(parent::provideFixtures(), [
/*
* Null value
*/
[
null,
null
]

/*
* Normal tags
*/
Expand Down