RemoveCharacters   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A filterWord() 0 8 2
1
<?php
2
3
namespace SixtyNine\Cloud\Filters;
4
5
/**
6
 * Remove unwanted characters from words.
7
 */
8
class RemoveCharacters extends AbstractFilter implements FilterInterface
9
{
10
    protected $unwantedCharacters;
11
12
    /**
13
     * @param array $unwantedCharacters Array of characters to be removed.
14
     */
15 8
    public function __construct($unwantedCharacters = null)
16
    {
17 8
        if (!$unwantedCharacters) {
18
            $unwantedCharacters = array(
19 8
                ':', '?', '!', '\'', '"', '(', ')', '[', ']',
20
            );
21
        }
22 8
        $this->unwantedCharacters = $unwantedCharacters;
23 8
    }
24
25
    /** {@inheritdoc} */
26 11
    public function filterWord($word)
27
    {
28 11
        foreach($this->unwantedCharacters as $p) {
29 11
            $word = str_replace($p, '', $word);
30
        }
31
32 11
        return $word;
33
    }
34
}