src/JCrowe/BadWordFilter/BadWordFilter.php
private function getBadWords()
    {
        if (!$this->badWords) {

            switch ($this->config['source']) {

                case 'file':
                    $this->badWords = $this->getBadWordsFromConfigFile();
                    break;

                case 'array':
                    $this->badWords = $this->getBadWordsFromArray();
                    break;

                case 'database':
                    $this->badWords = $this->getBadWordsFromDB();
                    break;

                default:
                    throw new \Exception('Config source was not a valid type. Valid types are: file, database, cache');
                    break;
            }

            if (!$this->isUsingCustomDefinedWordList()) {

                switch ($this->config['strictness']) {

                    case 'permissive':
                        $this->badWords = $this->getBadWordsByKey(['permissive']);
                        break;

                    case 'lenient':
                        $this->badWords = $this->getBadWordsByKey(['permissive', 'lenient']);
                        break;

                    case 'strict':
                        $this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict']);
                        break;

                    case 'very_strict':
                        $this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict', 'very_strict']);
                        break;

                    case 'strictest':
                        $this->badWords = $this->getBadWordsByKey([
                            'permissive',
                            'lenient',
                            'strict',
                            'very_strict',
                            'strictest'
                        ]);
                        break;

                    case 'misspellings':
                    case 'all':
                        $this->badWords = $this->getBadWordsByKey([
                            'permissive',
                            'lenient',
                            'strict',
                            'very_strict',
                            'strictest',
                            'misspellings'
                        ]);
                        break;

                    default:
                        $this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict', 'very_strict']);
                        break;

                }
            }

            if (!empty($this->config['also_check'])) {

                if (!is_array($this->config['also_check'])) {

                    $this->config['also_check'] = [$this->config['also_check']];
                }

                $this->badWords = array_merge($this->badWords, $this->config['also_check']);
            }
        }

        return $this->badWords;
    }
private function getBadWords()
    {
        if (!$this->badWords) {

            switch ($this->config['source']) {

                case 'file':
                    $this->badWords = $this->getBadWordsFromConfigFile();
                    break;

                case 'array':
                    $this->badWords = $this->getBadWordsFromArray();
                    break;

                case 'database':
                    $this->badWords = $this->getBadWordsFromDB();
                    break;

                default:
                    throw new \Exception('Config source was not a valid type. Valid types are: file, database, cache');
                    break;
            }

            if (!$this->isUsingCustomDefinedWordList()) {

                switch ($this->config['strictness']) {

                    case 'permissive':
                        $this->badWords = $this->getBadWordsByKey(['permissive']);
                        break;

                    case 'lenient':
                        $this->badWords = $this->getBadWordsByKey(['permissive', 'lenient']);
                        break;

                    case 'strict':
                        $this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict']);
                        break;

                    case 'very_strict':
                        $this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict', 'very_strict']);
                        break;

                    case 'strictest':
                        $this->badWords = $this->getBadWordsByKey([
                            'permissive',
                            'lenient',
                            'strict',
                            'very_strict',
                            'strictest'
                        ]);
                        break;

                    case 'misspellings':
                    case 'all':
                        $this->badWords = $this->getBadWordsByKey([
                            'permissive',
                            'lenient',
                            'strict',
                            'very_strict',
                            'strictest',
                            'misspellings'
                        ]);
                        break;

                    default:
                        $this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict', 'very_strict']);
                        break;

                }
            }

            if (!empty($this->config['also_check'])) {

                if (!is_array($this->config['also_check'])) {

                    $this->config['also_check'] = [$this->config['also_check']];
                }

                $this->badWords = array_merge($this->badWords, $this->config['also_check']);
            }
        }

        return $this->badWords;
    }
private function getBadWords ( ) { if ( ! $ this -> badWords ) { switch ( $ this -> config [ 'source' ] ) { case 'file' : $ this -> badWords = $ this -> getBadWordsFromConfigFile ( ) ; break ; case 'array' : $ this -> badWords = $ this -> getBadWordsFromArray ( ) ; break ; case 'database' : $ this -> badWords = $ this -> getBadWordsFromDB ( ) ; break ; default : throw new \ Exception ( 'Config source was not a valid type. Valid types are: file, database, cache' ) ; break ; } if ( ! $ this -> isUsingCustomDefinedWordList ( ) ) { switch ( $ this -> config [ 'strictness' ] ) { case 'permissive' : $ this -> badWords = $ this -> getBadWordsByKey ( [ 'permissive' ] ) ; break ; case 'lenient' : $ this -> badWords = $ this -> getBadWordsByKey ( [ 'permissive' , 'lenient' ] ) ; break ; case 'strict' : $ this -> badWords = $ this -> getBadWordsByKey ( [ 'permissive' , 'lenient' , 'strict' ] ) ; break ; case 'very_strict' : $ this -> badWords = $ this -> getBadWordsByKey ( [ 'permissive' , 'lenient' , 'strict' , 'very_strict' ] ) ; break ; case 'strictest' : $ this -> badWords = $ this -> getBadWordsByKey ( [ 'permissive' , 'lenient' , 'strict' , 'very_strict' , 'strictest' ] ) ; break ; case 'misspellings' : case 'all' : $ this -> badWords = $ this -> getBadWordsByKey ( [ 'permissive' , 'lenient' , 'strict' , 'very_strict' , 'strictest' , 'misspellings' ] ) ; break ; default : $ this -> badWords = $ this -> getBadWordsByKey ( [ 'permissive' , 'lenient' , 'strict' , 'very_strict' ] ) ; break ; } } if ( ! empty ( $ this -> config [ 'also_check' ] ) ) { if ( ! is_array ( $ this -> config [ 'also_check' ] ) ) { $ this -> config [ 'also_check' ] = [ $ this -> config [ 'also_check' ] ] ; } $ this -> badWords = array_merge ( $ this -> badWords , $ this -> config [ 'also_check' ] ) ; } } return $ this -> badWords ; }
Set the bad words array to the model if not already set and return it

@return array|void
@throws \Exception
Set the bad words array to the model if not already set and return it