Skip to content

Commit

Permalink
Added missing tests for certain classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miles Johnson committed Dec 29, 2014
1 parent 69d7df7 commit 165b7b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions Inflector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,18 @@ class Inflector {
}

/**
* Inflect a word for a filename. Studly cased and capitalized.
* Inflect a word for a filename. Remove an extension if it exists, and add a new extension.
*
* @param string $string
* @param string $ext
* @param bool $capitalize
* @return string
*/
public static function fileName(string $string, string $ext = 'php', bool $capitalize = true): string {
public static function fileName(string $string, string $ext = 'php'): string {
if (mb_strpos($string, '.') !== false) {
$string = mb_substr($string, 0, mb_strrpos($string, '.'));
}

$path = static::camelCase($string);

if (!$capitalize) {
$path = lcfirst($path);
}
$path = static::hyphenate($string);

if (mb_substr($path, -(mb_strlen($ext) + 1)) !== '.' . $ext) {
$path .= '.' . $ext;
Expand Down
4 changes: 2 additions & 2 deletions bootstrap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ function camel_case(string $string): string {
/**
* @see Titon\Utility\Inflector::fileName()
*/
function file_name(string $string): string {
return Inflector::fileName($string);
function file_name(string $string, string $ext = 'php'): string {
return Inflector::fileName($string, $ext);
}

/**
Expand Down

0 comments on commit 165b7b2

Please sign in to comment.