UpperFirst::filter()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * Particle.
4
 *
5
 * @link      http://github.com/particle-php for the canonical source repository
6
 * @copyright Copyright (c) 2005-2016 Particle (http://particle-php.com)
7
 * @license   https://github.com/particle-php/Filter/blob/master/LICENSE New BSD License
8
 */
9
namespace Particle\Filter\FilterRule;
10
11
use Particle\Filter\FilterRule;
12
13
/**
14
 * Class UpperFirst
15
 *
16
 * @package Particle\Filter\FilterRule
17
 */
18
class UpperFirst extends FilterRule
19
{
20
    /**
21
     * Uppercase the first character of the value
22
     *
23
     * @param mixed $value
24
     * @return string
25
     */
26 14
    public function filter($value)
27
    {
28 14
        if ($this->encodingFormat !== null) {
29 2
            $firstChar = mb_substr($value, 0, 1, $this->encodingFormat);
30 2
            $rest = mb_substr($value, 1, null, $this->encodingFormat);
31 2
            return mb_strtoupper($firstChar, $this->encodingFormat) . $rest;
32
        }
33
34 12
        $firstChar = mb_substr($value, 0, 1);
35 12
        $rest = mb_substr($value, 1);
36
37 12
        return mb_strtoupper($firstChar) . $rest;
38
    }
39
}
40