lithium\util\Inflector::camelize PHP Method

camelize() public static method

Takes a under_scored word and turns it into a CamelCased or camelBack word
public static camelize ( string $word, boolean $cased = true ) : string
$word string An under_scored or slugged word (i.e. `'red_bike'` or `'red-bike'`).
$cased boolean If false, first character is not upper cased
return string CamelCased version of the word (i.e. `'RedBike'`).
    public static function camelize($word, $cased = true)
    {
        $_word = $word;
        if (isset(static::$_camelized[$_word]) && $cased) {
            return static::$_camelized[$_word];
        }
        $word = str_replace(" ", "", ucwords(str_replace(array("_", '-'), " ", $word)));
        if (!$cased) {
            return lcfirst($word);
        }
        return static::$_camelized[$_word] = $word;
    }

Usage Example

Beispiel #1
0
 public function describe($entity, array $meta = array())
 {
     $var = "_" . Inflector::camelize($entity, false);
     if ($this->{$var}) {
         return $this->{$var};
     }
     return array();
 }
All Usage Examples Of lithium\util\Inflector::camelize