当前位置: 首页>>代码示例>>PHP>>正文


PHP Inflector::uncamelize方法代码示例

本文整理汇总了PHP中Thin\Inflector::uncamelize方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::uncamelize方法的具体用法?PHP Inflector::uncamelize怎么用?PHP Inflector::uncamelize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thin\Inflector的用法示例。


在下文中一共展示了Inflector::uncamelize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($db)
 {
     $this->orm = $db;
     $this->db = $db->db();
     $this->table = $db->table();
     $dir = Config::get('dir.blizz.store', session_save_path());
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table));
     if (!is_dir($this->dir)) {
         File::mkdir($this->dir);
     }
     $file = $this->dir . DS . 'data.db';
     $new = false;
     if (!is_file($file)) {
         File::create($file);
         $new = true;
         File::put($this->dir . DS . 'age.blizz', '');
     }
     $link = new SQLite3($file);
     Now::set("blizz.link.{$this->db}.{$this->table}", $link);
     if ($new) {
         $this->init();
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:30,代码来源:blizzstore.php

示例2: __call

 public function __call($event, $args)
 {
     if (substr($event, 0, 3) == 'get' && strlen($event) > 3) {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($event, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return $this->get($key);
     } elseif (substr($event, 0, 3) == 'set' && strlen($event) > 3) {
         $value = Arrays::first($args);
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($event, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return $this->set($key, $value);
     }
     if (true === $this->__has($event)) {
         array_push($args, $this);
         return $this->__fire($event, $args);
     } else {
         if (method_exists($this, $event)) {
             throw new Exception("The method {$event} is a native class' method. Please choose an other name.");
         }
         $value = Arrays::first($args);
         if ($value instanceof Closure) {
             $eventable = $this->__event($event, $value);
         } else {
             $set = function () use($value) {
                 return $value;
             };
             $eventable = $this->__event($event, $set);
         }
         return $this;
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:31,代码来源:Context.php

示例3: __call

 public function __call($func, $argv)
 {
     if (substr($func, 0, 3) == 'get' && strlen($func) > 3) {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $var = Inflector::lower($uncamelizeMethod);
         if (isset($this->{$var})) {
             $this->clean();
             return $this->{$var};
         } else {
             return null;
         }
     } elseif (substr($func, 0, 3) == 'set' && strlen($func) > 3) {
         $value = $argv[0];
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $var = Inflector::lower($uncamelizeMethod);
         $this->{$var} = $value;
         return $this->save();
     } elseif (substr($func, 0, 6) == 'forget' && strlen($func) > 6) {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 6)));
         $var = Inflector::lower($uncamelizeMethod);
         $this->erase($var);
         return $this->save();
     }
     $id = sha1($func);
     if (isset($this->{$id})) {
         if ($this->{$id} instanceof \Closure) {
             return call_user_func_array($this->{$id}, $argv);
         }
     }
     if (!is_callable($func) || substr($func, 0, 3) !== 'set' || substr($func, 0, 3) !== 'get') {
         throw new \BadMethodCallException(__CLASS__ . ' => ' . $func);
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:33,代码来源:Redis.php

示例4: __call

 public function __call($event, $args)
 {
     if (substr($event, 0, 3) == 'get') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($event, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return self::get($key);
     } elseif (substr($event, 0, 3) == 'set') {
         $value = Arrays::first($args);
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($event, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return self::set($key, $value);
     }
     if (true === self::__has($event)) {
         return self::__fire($event, $args);
     } else {
         $value = Arrays::first($args);
         if ($value instanceof Closure) {
             $eventable = self::__event($event, $value);
         } else {
             $set = function () use($value) {
                 return $value;
             };
             $eventable = self::__event($event, $set);
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:26,代码来源:Di.php

示例5: run

function run($lib, $args = null)
{
    $lib = Inflector::lower(Inflector::uncamelize($lib));
    $script = str_replace('_', DS, $lib) . '.php';
    if (fnmatch('*_*', $lib)) {
        $class = 'Thin\\' . str_replace('_', '\\', $lib);
        $tab = explode('\\', $class);
        $first = $tab[1];
        $class = str_replace('Thin\\' . $first, 'Thin\\' . ucfirst($first) . 'Libs', $class);
        if (count($tab) > 2) {
            for ($i = 2; $i < count($tab); $i++) {
                $seg = trim($tab[$i]);
                $class = str_replace('\\' . $seg, '\\' . ucfirst($seg), $class);
            }
        }
    } else {
        $class = 'Thin\\' . ucfirst($lib) . 'Libs';
    }
    $file = __DIR__ . DS . 'libs' . DS . $script;
    if (is_file($file)) {
        require_once $file;
        if (empty($args)) {
            return new $class();
        } else {
            if (!is_array($args)) {
                if (is_string($args)) {
                    if (fnmatch('*,*', $args)) {
                        $args = explode(',', str_replace(', ', ',', $args));
                    } else {
                        $args = [$args];
                    }
                } else {
                    $args = [$args];
                }
            }
            $methods = get_class_methods($class);
            if (in_array('instance', $methods)) {
                return call_user_func_array([$class, 'instance'], $args);
            } else {
                return construct($class, $args);
            }
        }
    }
    if (class_exists('Thin\\' . $lib)) {
        $c = 'Thin\\' . $lib;
        return new $c();
    }
    if (class_exists($lib)) {
        return new $lib();
    }
    throw new Exception("The library {$class} does not exist.");
}
开发者ID:schpill,项目名称:blog,代码行数:52,代码来源:helpers.php

示例6: __callStatic

 public static function __callStatic($method, $args)
 {
     $db = Inflector::uncamelize($method);
     if (fnmatch('*_*', $db)) {
         list($database, $table) = explode('_', $db, 2);
     } else {
         $database = SITE_NAME;
         $table = $db;
     }
     if (empty($args)) {
         return Db::instance($database, $table);
     } elseif (count($args) == 1) {
         $id = current($args);
         if (is_numeric($id)) {
             return Db::instance($database, $table)->find((int) $id);
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:18,代码来源:Entity.php

示例7: __callStatic

 public static function __callStatic($method, $args)
 {
     $db = Inflector::uncamelize($method);
     if (fnmatch('*_*', $db)) {
         list($database, $table) = explode('_', $db, 2);
     } else {
         $database = SITE_NAME;
         $table = $db;
     }
     if (empty($args)) {
         return new Redis($database, $table);
     } elseif (count($args) == 1) {
         $id = Arrays::first($args);
         if (is_numeric($id)) {
             return with(new Redis($database, $table))->find($id);
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:18,代码来源:Cacher.php

示例8: __call

 public function __call($func, $args)
 {
     if (substr($func, 0, strlen('get')) == 'get') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, strlen('get'))));
         $field = Inflector::lower($uncamelizeMethod);
         $default = count($args) == 1 ? Arrays::first($args) : null;
         $res = isAke($this->_data, $field, false);
         if (false !== $res) {
             return $res;
         } else {
             $resFk = isAke($this->_data, $field . '_id', false);
             if (false !== $resFk) {
                 $db = Db::instance($this->_db->db, $field);
                 $object = count($args) == 1 ? $args[0] : false;
                 if (!is_bool($object)) {
                     $object = false;
                 }
                 return $db->find($resFk, $object);
             } else {
                 if ($field[strlen($field) - 1] == 's' && isset($this->_data['id']) && $field[0] != '_') {
                     $db = Db::instance($this->_db->db, substr($field, 0, -1));
                     $object = count($args) == 1 ? $args[0] : false;
                     if (!is_bool($object)) {
                         $object = false;
                     }
                     $hasPivot = $this->hasPivot($db);
                     if (true === $hasPivot) {
                         $model = $db->model();
                         $pivots = $this->pivots($model)->exec();
                         $ids = [];
                         if (!empty($pivots)) {
                             foreach ($pivots as $pivot) {
                                 $id = isAke($pivot, substr($field, 0, -1) . '_id', false);
                                 if (false !== $id) {
                                     array_push($ids, $id);
                                 }
                             }
                             if (!empty($ids)) {
                                 return $db->where(['id', 'IN', implode(',', $ids)])->exec($object);
                             } else {
                                 return [];
                             }
                         }
                     } else {
                         $idField = $this->_db->table . '_id';
                         return $db->where([$idField, '=', $this->_data['id']])->exec($object);
                     }
                 } else {
                     return $default;
                 }
             }
         }
     } elseif (substr($func, 0, strlen('has')) == 'has') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, strlen('has'))));
         $field = Inflector::lower($uncamelizeMethod);
         $res = isAke($this->_data, $field, false);
         if (false !== $res) {
             return true;
         } else {
             $resFk = isAke($this->_data, $field . '_id', false);
             if (false !== $resFk) {
                 return true;
             } else {
                 if ($field[strlen($field) - 1] == 's' && isset($this->_data['id']) && $field[0] != '_') {
                     $db = Db::instance($this->_db->db, substr($field, 0, -1));
                     $hasPivot = $this->hasPivot($db);
                     if (true === $hasPivot) {
                         $model = $db->model();
                         $pivots = $this->pivots($model)->exec();
                         $ids = [];
                         if (!empty($pivots)) {
                             foreach ($pivots as $pivot) {
                                 $id = isAke($pivot, substr($field, 0, -1) . '_id', false);
                                 if (false !== $id) {
                                     array_push($ids, $id);
                                 }
                             }
                             return !empty($ids) ? true : false;
                         }
                     } else {
                         $idField = $this->_db->table . '_id';
                         $count = $db->where([$idField, '=', $this->_data['id']])->count();
                         return $count > 0 ? true : false;
                     }
                 }
             }
         }
         return false;
     } elseif (substr($func, 0, strlen('set')) == 'set') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, strlen('set'))));
         $field = Inflector::lower($uncamelizeMethod);
         if (!empty($args)) {
             $val = Arrays::first($args);
         } else {
             $val = null;
         }
         if (is_object($val)) {
             $val = (int) $val->id;
         }
         if (fnmatch('*_id', $field)) {
//.........这里部分代码省略.........
开发者ID:schpill,项目名称:standalone,代码行数:101,代码来源:Model.php

示例9: __call

 public function __call($method, $parameters)
 {
     if (substr($method, 0, 6) == 'findBy') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 6)));
         $field = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($parameters);
         return $this->findBy($field, $value);
     } elseif (substr($method, 0, 9) == 'findOneBy') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 9)));
         $field = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($parameters);
         return $this->findBy($field, $value, true);
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:14,代码来源:Store.php

示例10: __call

 public function __call($m, $a)
 {
     if ('or' == $m) {
         if (empty($this->wheres)) {
             return call_user_func_array([$this, 'where'], $a);
         }
         $this->check();
         $a[] = 'or';
         $this->wheres[] = $a;
     }
     if (fnmatch('findBy*', $m) && strlen($m) > 'findBy') {
         $field = Inflector::uncamelize(Inflector::lower(str_replace('findBy', '', $m)));
         if (strlen($field) > 0 && !empty($a)) {
             return $this->where([$field, '=', current($a)])->run();
         }
     }
     if (fnmatch('countBy*', $m) && strlen($m) > 'countBy') {
         $field = Inflector::uncamelize(Inflector::lower(str_replace('countBy', '', $m)));
         if (strlen($field) > 0 && !empty($a)) {
             return $this->where([$field, '=', current($a)])->count();
         }
     }
     if (fnmatch('groupBy*', $m) && strlen($m) > 'groupBy') {
         $field = Inflector::uncamelize(Inflector::lower(str_replace('groupBy', '', $m)));
         if (strlen($field) > 0) {
             return $this->groupBy($field);
         }
     }
     if (fnmatch('findOneBy*', $m) && strlen($m) > 'findOneBy') {
         $field = Inflector::uncamelize(Inflector::lower(str_replace('findOneBy', '', $m)));
         if (strlen($field) > 0 && !empty($a)) {
             $model = false;
             if (count($a) == 2) {
                 if (true === end($a)) {
                     $model = true;
                 }
             }
             return $this->where([$field, '=', current($a)])->first($model);
         }
     }
     if (fnmatch('firstBy*', $m) && strlen($m) > 'firstBy') {
         $field = Inflector::uncamelize(Inflector::lower(str_replace('firstBy', '', $m)));
         if (strlen($field) > 0 && !empty($a)) {
             $model = false;
             if (count($a) == 2) {
                 if (true === end($a)) {
                     $model = true;
                 }
             }
             return $this->where([$field, '=', current($a)])->first($model);
         }
     }
     if (fnmatch('lastBy*', $m) && strlen($m) > 'lastBy') {
         $field = Inflector::uncamelize(Inflector::lower(str_replace('lastBy', '', $m)));
         if (strlen($field) > 0 && !empty($a)) {
             $model = false;
             if (count($a) == 2) {
                 if (true === end($a)) {
                     $model = true;
                 }
             }
             return $this->where([$field, '=', current($a)])->last($model);
         }
     }
     return $this;
 }
开发者ID:schpill,项目名称:standalone,代码行数:66,代码来源:octadb.php

示例11: __call

 public function __call($m, $a)
 {
     $k = Inflector::uncamelize(substr($m, 3));
     if (fnmatch('get*', $m)) {
         $default = empty($a) ? null : current($a);
         return $this->get($k, $default);
     } elseif (fnmatch('set*', $m)) {
         return $this->set($k, current($a));
     } elseif (fnmatch('has*', $m)) {
         return $this->has($k);
     } else {
         $v = !empty($a) ? current($a) : true;
         return $this->set($m, $v);
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:15,代码来源:traits.php

示例12: __call

 public function __call($method, $parameters)
 {
     if (substr($method, 0, 6) == 'findBy') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 6)));
         $field = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($parameters);
         return $this->findBy($field, $value);
     } elseif (substr($method, 0, strlen('findObjectsBy')) == 'findObjectsBy') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, strlen('findObjectsBy'))));
         $field = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($parameters);
         return $this->findBy($field, $value, false, true);
     } elseif (substr($method, 0, 9) == 'findOneBy') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 9)));
         $field = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($parameters);
         return $this->findBy($field, $value, true);
     } elseif (substr($method, 0, 15) == 'findOneObjectBy') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 15)));
         $field = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($parameters);
         return $this->findBy($field, $value, true, true);
     } else {
         $settings = isAke(self::$configs, $this->entity);
         $event = isAke($settings, $method);
         if (!empty($event)) {
             if (is_callable($event)) {
                 if (version_compare(PHP_VERSION, '5.4.0', ">=")) {
                     $event = $event->bindTo($this);
                 }
                 return call_user_func_array($event, $parameters);
             }
         } else {
             if (count($parameters) == 1) {
                 $c = $this;
                 $cb = function () use($c) {
                     return $c;
                 };
                 return self::configs($this->entity, $method, Arrays::first($parameters), $cb);
             } else {
                 return $this->__fire($method, $parameters);
             }
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:45,代码来源:Mongonode.php

示例13: __call

 /**
  *
  * @method __call
  *
  * @param  [type]
  * @param  [type]
  *
  * @return [type]
  */
 public function __call($m, $a)
 {
     if (fnmatch('get*', $m)) {
         $key = Inflector::uncamelize(substr($m, 3));
         $default = empty($a) ? null : current($a);
         return $this->get($key, $default);
     } elseif (fnmatch('set*', $m)) {
         $key = Inflector::uncamelize(substr($m, 3));
         return $this->set($key, current($a));
     } elseif (fnmatch('has*', $m)) {
         $key = Inflector::uncamelize(substr($m, 3));
         return $this->has($key);
     } elseif (fnmatch('del*', $m)) {
         $key = Inflector::uncamelize(substr($m, 3));
         return $this->delete($key);
     } else {
         $closure = $this->get($m);
         if (is_string($closure) && fnmatch('*::*', $closure)) {
             list($c, $f) = explode('::', $closure, 2);
             try {
                 $i = lib('caller')->make($c);
                 return call_user_func_array([$i, $f], $a);
             } catch (\Exception $e) {
                 $default = empty($a) ? null : current($a);
                 return empty($closure) ? $default : $closure;
             }
         } else {
             if (is_callable($closure)) {
                 return call_user_func_array($closure, $a);
             }
             if (!empty($a) && empty($closure)) {
                 if (count($a) == 1) {
                     return $this->set($m, current($a));
                 }
             }
             $default = empty($a) ? null : current($a);
             return empty($closure) ? $default : $closure;
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:49,代码来源:now.php

示例14: __call

 public function __call($fn, $args)
 {
     $fields = array_keys($this->map['fields']);
     $method = substr($fn, 0, 2);
     $object = lcfirst(substr($fn, 2));
     if ('is' === $method && strlen($fn) > 2) {
         $field = Inflector::uncamelize($object);
         if (!Arrays::in($field, $fields)) {
             $field = $field . '_id';
             $model = Arrays::first($args);
             if ($model instanceof Container) {
                 $idFk = $model->id();
             } else {
                 $idFk = $model;
             }
             return $this->where("{$field} = {$idFk}");
         } else {
             return $this->where($field . ' = ' . Arrays::first($args));
         }
     }
     $method = substr($fn, 0, 3);
     $object = lcfirst(substr($fn, 3));
     if (strlen($fn) > 3) {
         if ('get' === $method) {
             $object = Inflector::uncamelize($object);
             return isset($this->{$object}) ? $this->{$object} : null;
         } else {
             if ('set' === $method) {
                 $object = Inflector::uncamelize($object);
                 $this->{$object} = Arrays::first($args);
                 return $this;
             } else {
                 if ('has' === $method) {
                     $object = Inflector::uncamelize($object);
                     return isset($this->{$object});
                 }
             }
         }
     }
     $method = substr($fn, 0, 4);
     $object = lcfirst(substr($fn, 4));
     if ('orIs' === $method && strlen($fn) > 4) {
         $field = Inflector::uncamelize($object);
         if (!Arrays::in($field, $fields)) {
             $field = $field . '_id';
             $model = Arrays::first($args);
             if ($model instanceof Container) {
                 $idFk = $model->id();
             } else {
                 $idFk = $model;
             }
             return $this->where("{$field} = {$idFk}", 'OR');
         } else {
             return $this->where($field . ' = ' . Arrays::first($args), 'OR');
         }
     } elseif ('like' === $method && strlen($fn) > 4) {
         $field = Inflector::uncamelize($object);
         $op = count($args) == 2 ? Arrays::last($args) : 'AND';
         return $this->like($field, Arrays::first($args), $op);
     }
     $method = substr($fn, 0, 5);
     $object = lcfirst(substr($fn, 5));
     if (strlen($fn) > 5) {
         if ('where' == $method) {
             $field = Inflector::uncamelize($object);
             if (!Arrays::in($field, $fields)) {
                 $field = $field . '_id';
                 $model = Arrays::first($args);
                 if ($model instanceof Container) {
                     $idFk = $model->id();
                 } else {
                     $idFk = $model;
                 }
                 return $this->where("{$field} = {$idFk}");
             } else {
                 return $this->where($field . ' ' . Arrays::first($args));
             }
         } elseif ('xorIs' === $method) {
             $field = Inflector::uncamelize($object);
             if (!Arrays::in($field, $fields)) {
                 $field = $field . '_id';
                 $model = Arrays::first($args);
                 if ($model instanceof Container) {
                     $idFk = $model->id();
                 } else {
                     $idFk = $model;
                 }
                 return $this->where("{$field} = {$idFk}", 'XOR');
             } else {
                 return $this->where($field . ' = ' . Arrays::first($args), 'XOR');
             }
         } elseif ('andIs' === $method) {
             $field = Inflector::uncamelize($object);
             if (!Arrays::in($field, $fields)) {
                 $field = $field . '_id';
                 $model = Arrays::first($args);
                 if ($model instanceof Container) {
                     $idFk = $model->id();
                 } else {
                     $idFk = $model;
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:inovi,代码行数:101,代码来源:Database.php

示例15: __call

 public function __call($m, $a)
 {
     $c = Now::get(str_replace(DS, '.', $this->_db->dir) . '.' . $m);
     if ($c && is_callable($c)) {
         $a[] = $this;
         return call_user_func_array($c, $a);
     } else {
         if (fnmatch('set*', $m)) {
             $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, strlen('set'))));
             $field = Inflector::lower($uncamelizeMethod);
             if (!empty($a)) {
                 $val = current($a);
             } else {
                 $val = null;
             }
             $this->{$field} = $val;
             return $this;
         } elseif (fnmatch('get*', $m)) {
             $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, strlen('set'))));
             $field = Inflector::lower($uncamelizeMethod);
             $default = count($a) == 1 ? current($a) : null;
             return isset($this->{$field}) ? $this->{$field} : $default;
         } else {
             return call_user_func_array([$this->_db], $a);
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:27,代码来源:flight.php


注:本文中的Thin\Inflector::uncamelize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。