ChangeCase   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 35
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A filterWord() 0 16 4
1
<?php
2
3
namespace SixtyNine\Cloud\Filters;
4
5
/**
6
 * Change the case of the words.
7
 */
8
class ChangeCase extends AbstractFilter implements FilterInterface
9
{
10
    const UPPERCASE = 'uppercase';
11
    const LOWERCASE = 'lowercase';
12
    const UCFIRST = 'ucfirst';
13
14
    /** @var string */
15
    protected $case;
16
17
    /**
18
     * @param string $case
19
     */
20 1
    public function __construct($case)
21
    {
22 1
        $this->case = $case;
23 1
    }
24
25
    /** {@inheritdoc} */
26 3
    public function filterWord($word)
27
    {
28 3
        switch ($this->case) {
29 3
            case self::UPPERCASE:
30 1
                $word = strtoupper($word);
31 1
                break;
32 2
            case self::UCFIRST:
33 1
                $word = ucfirst($word);
34 1
                break;
35 1
            case self::LOWERCASE:
36 1
                $word = strtolower($word);
37 1
                break;
38
        }
39
40 3
        return $word;
41
    }
42
}