Code Duplication    Length = 22-26 lines in 2 locations

src/helpers/Inflector.php 2 locations

@@ 95-120 (lines=26) @@
92
	);
93
94
	// TODO: cache results to speed up subsequent use?
95
	public static function pluralise( $string ) {
96
97
		// save some time in the case that singular and plural are the same
98
		if ( in_array( mb_strtolower( $string ), self::$uncountable ) )
99
			return $string;
100
101
102
		// check for irregular singular forms
103
		foreach ( self::$irregular as $pattern => $result )
104
		{
105
			$pattern = '/' . $pattern . '$/iu';
106
107
			if ( preg_match( $pattern, $string ) )
108
				return preg_replace( $pattern, $result, $string);
109
		}
110
111
		// check for matches using regular expressions
112
		foreach ( self::$plural as $pattern => $result )
113
		{
114
			if ( preg_match( $pattern, $string ) )
115
				return preg_replace( $pattern, $result, $string );
116
		}
117
118
		return $string;
119
120
	}
121
122
	// TODO: cache results to speed up subsequent use?
123
	public static function singularise( $string ) {
@@ 123-144 (lines=22) @@
120
	}
121
122
	// TODO: cache results to speed up subsequent use?
123
	public static function singularise( $string ) {
124
125
		// save some time in the case that singular and plural are the same
126
		if ( in_array(mb_strtolower($string), self::$uncountable) )
127
			return $string;
128
129
		// check for irregular plural forms
130
		foreach( self::$irregular as $result => $pattern ) {
131
			$pattern = '/' . $pattern . '$/iu';
132
			if( preg_match($pattern, $string) )
133
				return preg_replace($pattern, $result, $string);
134
		}
135
136
		// check for matches using regular expressions
137
		foreach( self::$singular as $pattern => $result ) {
138
			if( preg_match($pattern, $string) )
139
				return preg_replace($pattern, $result, $string);
140
		}
141
142
		return $string;
143
144
	}
145
146
}
147