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

SentenceCapitalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 9 2
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
}