Passed
Pull Request — master (#90)
by
unknown
09:04
created

SentenceCapitalizer::normalize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/* 
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace ValueParsers\Normalizers;
10
11
use InvalidArgumentException;
12
13
/**
14
 * Null implementation of StringNormalizer.
15
 *
16
 * @since 0.3
17
 *
18
 * @license GPL-2.0+
19
 * @author
20
 */
21
class SentenceCapitalizer implements StringNormalizer {
22
23
	/**
24
	 * @param string $value
25
	 *
26
	 * @throws InvalidArgumentException if $value is not a string
27
	 * @return string the normalized value
28
	 */
29
	public function normalize( $value ) {
30
		if ( !is_string( $value ) ) {
31
			throw new InvalidArgumentException( 'Parameter $value must be a string' );
32
		}
33
		$value = str_replace("_", " ",$value);
34
                $value=strtolower($value);
35
                $value=ucfirst($value) ; 
36
		return $value;
37
	}
38
}