RemoveFrontCharacters   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A filterWord() 0 10 3
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
}