From 076cde1a1bb24c1bd600f9021082a3e0e338ed46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arandi=20L=C3=B3pez?= Date: Mon, 8 May 2017 11:45:36 -0500 Subject: [PATCH] Fixes #1. Match in caseless way --- src/ProfaneValidator.php | 2 +- src/Str.php | 25 +++++++++++++++++++++++++ tests/ProfaneValidatorTest.php | 10 ++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/Str.php diff --git a/src/ProfaneValidator.php b/src/ProfaneValidator.php index 31e6430..b0dbacc 100644 --- a/src/ProfaneValidator.php +++ b/src/ProfaneValidator.php @@ -43,7 +43,7 @@ class ProfaneValidator */ public function isProfane($text) { - return str_contains($text, $this->badwords); + return Str::containsCaseless($text, $this->badwords); } public function getBadwords() diff --git a/src/Str.php b/src/Str.php new file mode 100644 index 0000000..42152e5 --- /dev/null +++ b/src/Str.php @@ -0,0 +1,25 @@ +assertTrue($profane->isProfane($word)); } + public function test_can_evaluate_as_caseless_mode() + { + $word = 'FUCK you BITCH if you read this.'; + $this->mockConfigs(); + + $profane = new ProfaneValidator(); + + $this->assertTrue($profane->isProfane($word)); + } + public function test_can_set_dictionary_when_you_pass_a_locale() { $this->mockConfigs();