RemoveFrontCharacters::filterWord()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace SixtyNine\Cloud\Filters;
4
5
/**
6
 * Remove trailing punctuation from words.
7
 */
8
class RemoveFrontCharacters extends AbstractFilter implements FilterInterface
9
{
10
    protected $punctuation;
11
12
    /**
13
     * @param array $punctuation Array of punctuation to be removed.
14
     */
15
    public function __construct($punctuation = array('\''))
16
    {
17
        $this->punctuation = $punctuation;
18
    }
19
20
    /** {@inheritdoc} */
21
    public function filterWord($word)
22
    {
23
        foreach($this->punctuation as $p) {
24
            if(substr($word, 1, 1) === $p) {
25
                $word = substr($word, 2);
26
            }
27
        }
28
29
        return $word;
30
    }
31
}