コード例 #1
0
ファイル: Event.php プロジェクト: zumba/amplitude-php
 /**
  * Normalized the name, by attempting to camelcase / underscore it to see if it matches any built-in property names.
  *
  * If it matches a built-in property name, will return the normalized property name.  Otherwise returns the name
  * un-modified.
  *
  * @param string $name
  * @return string
  */
 protected function normalize($name)
 {
     if (isset($this->availableVars[$name])) {
         return $name;
     }
     if (preg_match('/^[a-zA-Z_]+$/', $name)) {
         // No spaces or unexpected vars, this could be camelcased version or underscore version of a built-in
         // var name, check to see if it matches
         $underscore = Inflector::underscore($name);
         if (isset($this->availableVars[$underscore])) {
             return $underscore;
         }
         // In case it is one of the camel-cased versions
         $camel = Inflector::camelCase($name);
         if (isset($this->availableVars[$camel])) {
             return $camel;
         }
     }
     // Could not find name, just use original un-altered, probably used in event_properties
     return $name;
 }
コード例 #2
0
ファイル: Inflector.php プロジェクト: titon/utility-old
 /**
  * Inflect a word for a database table name. Formatted as plural and camel case with the first letter lowercase.
  *
  * @param string $string
  * @return string
  */
 public static function tableName($string)
 {
     return static::cache(array(__METHOD__, $string), function () use($string) {
         return lcfirst(Inflector::camelCase(Inflector::pluralize($string)));
     });
 }