for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Ahc\Cli\Helper;
/**
* Performs inflection on strings.
*
* @author Jitendra Adhikari <[email protected]>
* @license MIT
* @link https://github.com/adhocore/cli
*/
trait InflectsString
{
* Convert a string to camel case.
* @param string $string
* @return string
public function toCamelCase(string $string): string
$words = \str_replace(['-', '_'], ' ', $string);
$words = \str_replace(' ', '', \ucwords($words));
return \lcfirst($words);
}
* Convert a string to capitalized words.
public function toWords(string $string): string
$words = \trim(\str_replace(['-', '_'], ' ', $string));
return \ucwords($words);