From 73b204b6cb4db5c7889774c23b7148ad6f31bdcd Mon Sep 17 00:00:00 2001 From: Luca Sartori Date: Tue, 28 Aug 2018 04:58:06 +0200 Subject: [PATCH] Added support for words from array --- src/CensorWords.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/CensorWords.php b/src/CensorWords.php index 0eede25..a453422 100644 --- a/src/CensorWords.php +++ b/src/CensorWords.php @@ -57,6 +57,17 @@ public function addDictionary($dictionary) $this->badwords = array_merge($this->badwords, $this->readBadWords($dictionary)); } + /** + * Adds more words to current bad words list from an array of words. + * + * @param array + */ + public function addFromArray($words) + { + $badwords = array_merge($this->badwords, $words); + $this->badwords = array_keys(array_count_values($badwords)); + } + /** * Read bad words list from dictionar(y|ies) and return it *