diff --git a/src/DaveChild/TextStatistics/Text.php b/src/DaveChild/TextStatistics/Text.php index 6210848..4c124e3 100644 --- a/src/DaveChild/TextStatistics/Text.php +++ b/src/DaveChild/TextStatistics/Text.php @@ -20,7 +20,7 @@ public static function cleanText($strText) { // Check for boolean before processing as string - if (is_bool($strText)) { + if (is_bool($strText) || is_null($strText)) { return ''; } diff --git a/tests/TextStatisticsTest.php b/tests/TextStatisticsTest.php index 45b57dd..ffde722 100644 --- a/tests/TextStatisticsTest.php +++ b/tests/TextStatisticsTest.php @@ -28,6 +28,7 @@ public function tearDown(): void -------------------- */ public function testCleaning() { + $this->assertSame('', DaveChild\TextStatistics\Text::cleanText(null)); $this->assertSame('', DaveChild\TextStatistics\Text::cleanText(false)); $this->assertSame('There once was a little sausage named Baldrick. and he lived happily ever after.', DaveChild\TextStatistics\Text::cleanText('There once was a little sausage named Baldrick. . . . And he lived happily ever after.!! !??')); }