本文整理汇总了PHP中Thin\Inflector::lower方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::lower方法的具体用法?PHP Inflector::lower怎么用?PHP Inflector::lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thin\Inflector
的用法示例。
在下文中一共展示了Inflector::lower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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);
}
}
}
示例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;
}
}
示例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);
}
}
示例4: __destruct
public function __destruct()
{
/* On efface le model de la base tampon et on vide la base */
$modelFile = APPLICATION_PATH . DS . 'models' . DS . 'Bigdata' . DS . 'models' . DS . Inflector::lower($this->to->db) . DS . ucfirst(Inflector::lower($this->to->table)) . '.php';
File::delete($modelFile);
$this->to->drop();
}
示例5: __callStatic
public static function __callStatic($fn, $args)
{
$method = Inflector::upper($fn);
if (count($args) < 2) {
throw new Exception("You must provide at least a path and a mvc pattern.");
}
$path = $args[0];
$mvc = $args[1];
$argsRoute = [];
$optionsRoute = [];
if (count($args) > 2) {
$argsRoute = $args[2];
if (count($args) > 3) {
array_shift($args);
array_shift($args);
array_shift($args);
$optionsRoute = $args;
}
}
list($module, $controller, $action) = explode('::', $mvc, 3);
if (!isset($module) || !isset($controller) || !isset($action)) {
throw new Exception("MVC '{$mvc}' is incorrect.");
}
return ['name' => Inflector::lower($method) . '::' . $module . '::' . $controller . '::' . $action, 'method' => $method, 'path' => $path, 'module' => $module, 'controller' => $controller, 'action' => $action, 'args' => $argsRoute, 'options' => $optionsRoute];
}
示例6: callback
public static function callback($class, $method, Closure $cb)
{
$callbackClass = ucfirst(Inflector::lower($class));
if (!class_exists('Thin\\' . $callbackClass)) {
eval("namespace Thin; class {$callbackClass} extends Alias {}");
}
static::$cb[$callbackClass][$method] = $cb;
}
示例7: register
public function register()
{
$args = func_get_args();
if (count($args) < 1 || count($args) > 1) {
throw new Exception("You need to provide a helper to register.");
}
$helper = reset($args);
$this->type = 'helpers';
$this->file = APPLICATION_PATH . DS . 'helpers' . DS . ucfirst(Inflector::lower($helper)) . DS . ucfirst(Inflector::lower($helper)) . '.php';
$this->class = 'ThinHelper\\' . ucfirst(Inflector::lower($helper)) . '\\' . ucfirst(Inflector::lower($helper));
return $this->factory();
}
示例8: 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.");
}
示例9: make
public static function make($db, $what)
{
if (is_string($what)) {
$file = APPLICATION_PATH . DS . 'models' . DS . 'Bigdata' . DS . 'views' . DS . $db->db . DS . ucfirst(I::lower($db->table)) . DS . I::camelize($what) . '.php';
if (files()->exists($file)) {
require_once $file;
$class = '\\Thin\\' . ucfirst(I::lower($db->db)) . ucfirst(I::lower($db->table)) . 'View';
return $class::make($db);
} else {
return $db;
}
} elseif (A::is($what)) {
$nameview = 'view_' . $db->db . '_' . $db->table . '_' . sha1(serialize($what));
$ageDb = $db->getage();
$viewDb = Db::instance($db->db, $nameview);
$ageView = $db->getage();
$exists = strlen($db->cache()->get('dbRedis.views.' . $nameview)) ? true : false;
if ($ageView < $ageDb || !$exists) {
$viewDb->getCollection()->remove();
foreach ($what as $wh) {
$op = 'AND';
if (count($wh) == 4) {
$op = $wh[3];
unset($wh[3]);
}
$db = $db->where($wh);
}
$res = $db->exec();
foreach ($res as $row) {
$viewDb->saveView($row);
}
$db->cache()->set('dbRedis.views.' . $nameview, 1);
}
return $viewDb;
}
}
示例10: compare
private function compare($comp, $op, $value)
{
$res = false;
if (strlen($comp) && strlen($op) && strlen($value)) {
$comp = Inflector::lower(Inflector::unaccent($comp));
$value = Inflector::lower(Inflector::unaccent($value));
switch ($op) {
case '=':
$res = sha1($comp) == sha1($value);
break;
case '>=':
$res = $comp >= $value;
break;
case '>':
$res = $comp > $value;
break;
case '<':
$res = $comp < $value;
break;
case '<=':
$res = $comp <= $value;
break;
case '<>':
case '!=':
$res = sha1($comp) != sha1($value);
break;
case 'LIKE':
$value = str_replace("'", '', $value);
$value = str_replace('%', '*', $value);
$res = fnmatch($value, $comp);
break;
case 'NOTLIKE':
$value = str_replace("'", '', $value);
$value = str_replace('%', '*', $value);
$check = fnmatch($value, $comp);
$res = !$check;
break;
case 'LIKESTART':
$value = str_replace("'", '', $value);
$value = str_replace('%', '', $value);
$res = substr($comp, 0, strlen($value)) === $value;
break;
case 'LIKEEND':
$value = str_replace("'", '', $value);
$value = str_replace('%', '', $value);
if (!strlen($comp)) {
$res = true;
}
$res = substr($comp, -strlen($value)) === $value;
break;
case 'IN':
$value = str_replace('(', '', $value);
$value = str_replace(')', '', $value);
$tabValues = explode(',', $value);
$res = Arrays::in($comp, $tabValues);
break;
case 'NOTIN':
$value = str_replace('(', '', $value);
$value = str_replace(')', '', $value);
$tabValues = explode(',', $value);
$res = !Arrays::in($comp, $tabValues);
break;
}
}
return $res;
}
示例11: makeResults
private function makeResults($fetch = true)
{
if (count($this->fields)) {
$pk = "{$this->database}.{$this->table}." . $this->pk();
$hasPk = false;
$select = '';
foreach ($this->fields as $field) {
if (false === $hasPk) {
$hasPk = $field == $pk;
}
list($db, $table, $tmpField) = explode('.', $field, 3);
$as = isAke($this->as, $field, null);
if ($db == $this->database && $table == $this->table) {
if (is_null($as)) {
$select .= "{$field}, ";
} else {
$select .= "{$field} AS {$as}, ";
}
} else {
if (is_null($as)) {
$select .= "{$field} AS " . 'join_' . str_replace('.', '_', Inflector::lower($field)) . ", ";
} else {
$select .= "{$field} AS {$as}, ";
}
}
}
if (false === $hasPk) {
$select .= "{$pk}, ";
}
} else {
$fields = array_keys($this->map['fields']);
$select = '';
foreach ($fields as $field) {
$select .= "{$this->database}.{$this->table}.{$field}, ";
}
}
$select = substr($select, 0, -2);
if (!count($this->joins)) {
$query = "SELECT {$select} FROM {$this->database}.{$this->table} WHERE ";
} else {
$query = "SELECT {$select} FROM {$this->database}.{$this->table} ";
foreach ($this->joins as $join) {
list($model, $condition, $type) = $join;
$joinKey = $model->table . '_id';
$fpk = $model->pk();
if (is_null($condition)) {
$query .= "{$type} JOIN {$model->database}.{$model->table} ON {$this->database}.{$this->table}.{$joinKey} = {$model->database}.{$model->table}.{$fpk}\n";
} else {
$query .= "{$type} JOIN {$model->database}.{$model->table} ON {$condition}\n";
}
}
$query .= "WHERE\n";
}
if (count($this->wheres)) {
$first = true;
foreach ($this->wheres as $where) {
list($op, $condition) = $where;
if (count($this->joins)) {
$condition = repl('NOT LIKE', 'NOTLIKE', $condition);
$condition = repl('NOT IN', 'NOTIN', $condition);
list($field, $operator, $value) = explode(' ', $condition, 3);
if ($value instanceof Container) {
$value = $value->id();
$field = $field . '_id';
}
if (!strstr($field, '.')) {
$field = "{$this->database}.{$this->table}.{$field}";
}
$condition = "{$field} {$operator} {$value}";
$condition = repl('NOTLIKE', 'NOT LIKE', $condition);
$condition = repl('NOTIN', 'NOT IN', $condition);
}
if (false === $first) {
$query .= " {$op} {$condition}";
} else {
$query .= $condition;
}
$first = false;
}
} else {
$query .= '1 = 1';
}
if (count($this->groupBys)) {
$query .= ' GROUP BY ';
$first = true;
foreach ($this->groupBys as $groupBy) {
if (false === $first) {
if (!strstr($groupBy, '.')) {
$query .= ", {$this->database}.{$this->table}.{$groupBy}";
} else {
$query .= ", {$groupBy}";
}
} else {
if (!strstr($groupBy, '.')) {
$query .= "{$this->database}.{$this->table}.{$groupBy}";
} else {
$query .= $groupBy;
}
}
$first = false;
//.........这里部分代码省略.........
示例12: __call
public function __call($m, $a)
{
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);
}
}
示例13: compare
private function compare($comp, $op, $value)
{
$res = false;
if (strlen($comp) && strlen($op) && !empty($value)) {
if (is_numeric($comp)) {
if (fnmatch('*,*', $comp) || fnmatch('*.*', $comp)) {
$comp = floatval($comp);
} else {
$comp = intval($comp);
}
}
if (is_numeric($value)) {
if (fnmatch('*,*', $value) || fnmatch('*.*', $value)) {
$value = floatval($value);
} else {
$value = intval($value);
}
}
switch ($op) {
case '=':
$res = sha1($comp) == sha1($value);
break;
case '=i':
$comp = Inflector::lower(Inflector::unaccent($comp));
$value = Inflector::lower(Inflector::unaccent($value));
$res = sha1($comp) == sha1($value);
break;
case '>=':
$res = $comp >= $value;
break;
case '>':
$res = $comp > $value;
break;
case '<':
$res = $comp < $value;
break;
case '<=':
$res = $comp <= $value;
break;
case '<>':
case '!=':
$res = sha1($comp) != sha1($value);
break;
case 'LIKE':
$value = str_replace("'", '', $value);
$value = str_replace('%', '*', $value);
$res = fnmatch($value, $comp);
break;
case 'NOT LIKE':
case 'NOTLIKE':
$value = str_replace("'", '', $value);
$value = str_replace('%', '*', $value);
$check = fnmatch($value, $comp);
$res = !$check;
break;
case 'BETWEEN':
$res = $comp >= $value[0] && $comp <= $value[1];
break;
case 'NOT BETWEEN':
case 'NOTBETWEEN':
$res = $comp < $value[0] || $comp > $value[1];
break;
case 'LIKE START':
case 'LIKESTART':
$value = str_replace(["'", '%'], '', $value);
$res = substr($comp, 0, strlen($value)) === $value;
break;
case 'LIKE END':
case 'LIKEEND':
$value = str_replace(["'", '%'], '', $value);
if (!strlen($comp)) {
$res = true;
}
$res = substr($comp, -strlen($value)) === $value;
break;
case 'IN':
$value = str_replace('(', '', $value);
$value = str_replace(')', '', $value);
$tabValues = explode(',', $value);
$res = in_array($comp, $tabValues);
break;
case 'NOT IN':
case 'NOTIN':
$value = str_replace('(', '', $value);
$value = str_replace(')', '', $value);
$tabValues = explode(',', $value);
$res = !in_array($comp, $tabValues);
break;
}
}
return $res;
}
示例14: __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);
}
}
示例15: __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);
} 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 {
throw new Exception("The method '{$method}' is not callable.");
}
}
}