Skip to content

Commit 594f495

Browse files
committed
Add wordify support
1 parent 7587104 commit 594f495

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Util/Inflector.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function underscore($word)
2121
}
2222
return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word));
2323
}
24+
2425
/**
2526
* Convert word into dasherized format (e.g. some-name-here).
2627
*
@@ -31,6 +32,7 @@ public function dasherize($word)
3132
{
3233
return str_replace('_', '-', $this->underscore($word));
3334
}
35+
3436
/**
3537
* Convert word into camelized format (e.g. someNameHere).
3638
*
@@ -41,6 +43,7 @@ public function camelize($word)
4143
{
4244
return lcfirst($this->studlify($word));
4345
}
46+
4447
/**
4548
* Convert word into studly caps format (e.g. SomeNameHere).
4649
*
@@ -49,6 +52,17 @@ public function camelize($word)
4952
*/
5053
public function studlify($word)
5154
{
52-
return str_replace(" ", "", ucwords(strtr($this->underscore($word), "_", " ")));
55+
return str_replace(" ", "", $this->wordify($word));
56+
}
57+
58+
/**
59+
* Convert word into wordified format (e.g. Some Name Here).
60+
*
61+
* @param string $word
62+
* @return string
63+
*/
64+
public function wordify($word)
65+
{
66+
return ucwords(strtr($this->underscore($word), "_", " "));
5367
}
5468
}

0 commit comments

Comments
 (0)