Completed
Push — master ( 5ecb1b...bcc24a )
by Adam
06:21
created

BadWordsChecker   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isBadWord() 0 10 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\ReviewBundle\Service\Checker;
14
15
use Expalmer\PhpBadWords\PhpBadWords;
16
use ReflectionClass;
17
18
/**
19
 * Class BadWordsChecker
20
 *
21
 * @author  Adam Piotrowski <[email protected]>
22
 */
23
class BadWordsChecker
24
{
25
    public function isBadWord(string $phrase): bool
26
    {
27
        $reflection = new ReflectionClass($this);
28
        $directory  = dirname($reflection->getFileName());
29
        $badWords   = new PhpBadWords();
30
        $badWords->setDictionaryFromFile($directory . '/dictionary.php');
31
        $badWords->setText($phrase);
32
        
33
        return $badWords->check();
34
    }
35
}
36