RemoveFrontCharacters::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
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
}