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


PHP Inflector::camelize方法代码示例

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


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

示例1: describe

 public function describe($entity, array $meta = array())
 {
     $var = "_" . Inflector::camelize($entity, false);
     if ($this->{$var}) {
         return $this->{$var};
     }
     return array();
 }
开发者ID:WarToaster,项目名称:HangOn,代码行数:8,代码来源:MockSource.php

示例2: _init

 /**
  * undocumented function
  *
  * @return void
  */
 protected function _init()
 {
     $class = Inflector::camelize($this->_config['reporter']);
     if (!($reporter = Libraries::locate('test.reporter', $class))) {
         throw new Exception("{$class} is not a valid reporter");
     }
     $this->reporter = new $reporter();
     $this->group = $this->_config['group'];
     $this->filters = $this->_config['filters'];
     $this->title = $this->_config['title'] ?: $this->_config['title'];
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:16,代码来源:Report.php

示例3: run

 /**
  * Auto run the help command.
  *
  * @param string $command Name of the command to return help about.
  * @return boolean
  */
 public function run($command = null)
 {
     $message = 'Lithium console started in the ' . Environment::get() . ' environment.';
     $message .= ' Use the --env=environment key to alter this.';
     $this->out($message);
     if (!$command) {
         $this->_renderCommands();
         return true;
     }
     if (!preg_match('/\\\\/', $command)) {
         $command = Inflector::camelize($command);
     }
     if (!($class = Libraries::locate('command', $command))) {
         $this->error("Command `{$command}` not found");
         return false;
     }
     if (strpos($command, '\\') !== false) {
         $command = join('', array_slice(explode("\\", $command), -1));
     }
     $command = strtolower(Inflector::slug($command));
     $run = null;
     $methods = $this->_methods($class);
     $properties = $this->_properties($class);
     $info = Inspector::info($class);
     $this->out('USAGE', 'heading');
     if (isset($methods['run'])) {
         $run = $methods['run'];
         unset($methods['run']);
         $this->_renderUsage($command, $run, $properties);
     }
     foreach ($methods as $method) {
         $this->_renderUsage($command, $method);
     }
     if (!empty($info['description'])) {
         $this->nl();
         $this->_renderDescription($info);
         $this->nl();
     }
     if ($properties || $methods) {
         $this->out('OPTIONS', 'heading');
     }
     if ($run) {
         $this->_render($run['args']);
     }
     if ($methods) {
         $this->_render($methods);
     }
     if ($properties) {
         $this->_render($properties);
     }
     return true;
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:58,代码来源:Help.php

示例4: apply

 public function apply($testable, array $config = array())
 {
     $tokens = $testable->tokens();
     $filtered = $testable->findAll(array(T_VARIABLE));
     foreach ($filtered as $id) {
         $token = $tokens[$id];
         $isntSuperGlobal = !isset($this->_superglobals[$token['content']]);
         if ($isntSuperGlobal) {
             $name = preg_replace('/(\\$_?|_+$)/', '', $token['content']);
             if ($name !== Inflector::camelize($name, false)) {
                 $this->addViolation(array('message' => "Variable {$name} is not camelBack style", 'line' => $token['line']));
             }
         }
     }
 }
开发者ID:unionofrad,项目名称:li3_quality,代码行数:15,代码来源:HasCorrectVariableNames.php

示例5: apply

 /**
  * Will iterate the tokens looking for a T_CLASS which should be
  * in CamelCase and match the file name
  *
  * @param  Testable $testable The testable object
  * @return void
  */
 public function apply($testable, array $config = array())
 {
     $tokens = $testable->tokens();
     $pathinfo = pathinfo($testable->config('path'));
     if ($pathinfo['extension'] !== 'php') {
         return;
     }
     $filtered = $testable->findAll(array(T_CLASS));
     foreach ($filtered as $key) {
         $token = $tokens[$key];
         $className = $tokens[$key + 2]['content'];
         if ($className !== Inflector::camelize($className)) {
             $this->addViolation(array('message' => 'Class name is not in CamelCase style', 'line' => $token['line']));
         } elseif ($className !== $pathinfo['filename']) {
             $this->addViolation(array('message' => 'Class name and file name should match', 'line' => $token['line']));
         }
     }
 }
开发者ID:unionofrad,项目名称:li3_quality,代码行数:25,代码来源:HasCorrectClassName.php

示例6: apply

 /**
  * Will iterate the tokens looking for functions validating they have the
  * correct camelBack naming style.
  *
  * @param  Testable $testable The testable object
  * @return void
  */
 public function apply($testable, array $config = array())
 {
     $tokens = $testable->tokens();
     $filtered = $testable->findAll(array(T_FUNCTION));
     foreach ($filtered as $key) {
         $token = $tokens[$key];
         $label = Parser::label($key, $tokens);
         $modifiers = Parser::modifiers($key, $tokens);
         $isClosure = Parser::closure($key, $tokens);
         if (in_array($label, $this->_magicMethods)) {
             continue;
         }
         if ($testable->findNext(array(T_PROTECTED), $modifiers) !== false) {
             $label = preg_replace('/^_/', '', $label);
         }
         if (!$isClosure && $label !== Inflector::camelize($label, false)) {
             $this->addViolation(array('message' => 'Function "' . $label . '" is not in camelBack style', 'line' => $tokens[$tokens[$key]['parent']]['line']));
         }
     }
 }
开发者ID:unionofrad,项目名称:li3_quality,代码行数:27,代码来源:HasCorrectFunctionNames.php

示例7: _instance

 /**
  * Get an instance of a sub-command
  *
  * @param string $name the name of the sub-command to instantiate
  * @param array $config
  * @return object;
  */
 protected function _instance($name, array $config = array())
 {
     if ($class = Libraries::locate('command.create', Inflector::camelize($name))) {
         $this->request->params['template'] = $this->template;
         return new $class(array('request' => $this->request, 'classes' => $this->_classes));
     }
     return parent::_instance($name, $config);
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:15,代码来源:Create.php

示例8: relationFieldName

 /**
  * Returns the field name of a relation name (camelBack).
  *
  * @param string The type of the relation.
  * @param string The name of the relation.
  * @return string
  */
 public function relationFieldName($type, $name)
 {
     $fieldName = Inflector::camelize($name, false);
     if (preg_match('/Many$/', $type)) {
         $fieldName = Inflector::pluralize($fieldName);
     } else {
         $fieldName = Inflector::singularize($fieldName);
     }
     return $fieldName;
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:17,代码来源:MongoDb.php

示例9:

<?php
/**
 * li3_flash_message plugin for Lithium: the most rad php framework.
 *
 * @copyright     Copyright 2010, Michael Hüneburg
 * @license       http://opensource.org/licenses/bsd-license.php The BSD License
 */
$class = (!empty($class)) ? $class : null;
$class = \lithium\util\Inflector::camelize($class);
?>
<div class="message<?= $class;  ?>">
	<?= $message; ?>
</div>
开发者ID:rich97,项目名称:li3_flash,代码行数:13,代码来源:flash.html.php

示例10: requestAction

	/**
	 *  requestAction() is a shortcut method to pulling back return data from any controller's method.
	 *  Normally, you'd have to manually instantiate the class, call the method, and pass arguments...
	 *  Which really isn't a big deal, but this is a convience to that. It also let's you pass a conveient library option.
	 *
	 *  @param $options array[required] This is your basic controller/action url in array format, you can also pass 'library'
	 *  @return Mixed data from the controller's method to use in your view template
	*/
	public function requestAction($options=array()) {
		$defaults = array('library' => null, 'args' => null);
		$options += $defaults;
		
		if((!isset($options['controller'])) || (!isset($options['action']))) {
			return false;
		}
		
		$controller_name = Inflector::camelize($options['controller']);
		if(empty($options['library'])) {
			$class = '\minerva\controllers\\'.$controller_name.'Controller';
		} else {
			$class = '\minerva\libraries\\'.$options['library'].'\controllers\\'.$controller_name.'Controller'; 			
		}
		$controller = new $class();		
		
		return $controller->{$options['action']}($options['args']);		
	}
开发者ID:nateabele,项目名称:Minerva-Plugin,代码行数:26,代码来源:Block.php

示例11: _callable

 /**
  * Determines Command to use for current request. If
  *
  * @param string $request
  * @param string $params
  * @param string $options
  * @return class \lithium\console\COmmand
  */
 protected static function _callable($request, $params, $options)
 {
     $params = compact('request', 'params', 'options');
     return static::_filter(__FUNCTION__, $params, function ($self, $params, $chain) {
         extract($params, EXTR_OVERWRITE);
         $name = $class = $params['command'];
         if (!$name) {
             $request->params['args'][0] = $name;
             $name = $class = '\\lithium\\console\\command\\Help';
         }
         if ($class[0] !== '\\') {
             $name = Inflector::camelize($class);
             $class = Libraries::locate('command', $name);
         }
         if (class_exists($class)) {
             return new $class(compact('request'));
         }
         throw new UnexpectedValueException("Command `{$name}` not found");
     });
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:28,代码来源:Dispatcher.php

示例12: testConfigManipulation

 public function testConfigManipulation()
 {
     $config = MockDispatcher::config();
     $expected = array('rules' => array());
     $this->assertEqual($expected, $config);
     MockDispatcher::config(array('rules' => array('admin' => array('action' => 'admin_{:action}'))));
     Router::connect('/', array('controller' => 'test', 'action' => 'test', 'admin' => true));
     MockDispatcher::run(new Request(array('url' => '/')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'admin_test', 'controller' => 'Test', 'admin' => true);
     $this->assertEqual($expected, $result->params);
     MockDispatcher::config(array('rules' => array('action' => array('action' => function ($params) {
         return Inflector::camelize(strtolower($params['action']), false);
     }))));
     MockDispatcher::$dispatched = array();
     Router::reset();
     Router::connect('/', array('controller' => 'test', 'action' => 'TeST-camelize'));
     MockDispatcher::run(new Request(array('url' => '/')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'testCamelize', 'controller' => 'Test');
     $this->assertEqual($expected, $result->params);
     MockDispatcher::config(array('rules' => function ($params) {
         if (isset($params['admin'])) {
             return array('special' => array('action' => 'special_{:action}'));
         }
         return array();
     }));
     MockDispatcher::$dispatched = array();
     Router::reset();
     Router::connect('/', array('controller' => 'test', 'action' => 'test', 'admin' => true));
     Router::connect('/special', array('controller' => 'test', 'action' => 'test', 'admin' => true, 'special' => true));
     MockDispatcher::run(new Request(array('url' => '/')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'test', 'controller' => 'Test', 'admin' => true);
     $this->assertEqual($expected, $result->params);
     MockDispatcher::run(new Request(array('url' => '/special')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'special_test', 'controller' => 'Test', 'admin' => true, 'special' => true);
     $this->assertEqual($expected, $result->params);
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:40,代码来源:DispatcherTest.php

示例13: _class

 /**
  * Get the class name for the migration.
  *
  * @param string $request
  * @return string
  */
 protected function _class($request)
 {
     return Inflector::camelize($request->action);
 }
开发者ID:djordje,项目名称:li3_migrations,代码行数:10,代码来源:Migration.php

示例14: _getData

 /**
  * Get record data as an array
  *
  * @param bool $allProperties If true, get also properties without getter methods
  * @return array Data
  */
 protected function _getData($allProperties = false)
 {
     $data = array();
     foreach ($this->_getEntityFields() as $field) {
         $method = 'get' . Inflector::camelize($field);
         if (method_exists($this, $method) && is_callable(array($this, $method))) {
             $data[$field] = $this->{$method}();
         } elseif ($allProperties && property_exists($this, $field)) {
             $data[$field] = $this->{$field};
         }
     }
     if (isset($name)) {
         return array_key_exists($name, $data) ? $data[$name] : null;
     }
     return $data;
 }
开发者ID:mariano,项目名称:li3_doctrine2,代码行数:22,代码来源:BaseEntity.php

示例15: applyRules

 /**
  * Attempts to apply a set of formatting rules from `$_rules` to a `$params` array, where each
  * formatting rule is applied if the key of the rule in `$_rules` is present and not empty in
  * `$params`.  Also performs sanity checking against `$params` to ensure that no value
  * matching a rule is present unless the rule check passes.
  *
  * @param array $params An array of route parameters to which rules will be applied.
  * @return array Returns the `$params` array with formatting rules applied to array values.
  */
 public static function applyRules(&$params)
 {
     $values = array();
     $rules = static::$_rules;
     if (!$params) {
         return false;
     }
     if (isset($params['controller']) && is_string($params['controller'])) {
         $controller = $params['controller'];
         if (strpos($controller, '.') !== false) {
             list($library, $controller) = explode('.', $controller);
             $controller = $library . '.' . Inflector::camelize($controller);
             $params += compact('library');
         } elseif (strpos($controller, '\\') === false) {
             $controller = Inflector::camelize($controller);
             if (isset($params['library'])) {
                 $controller = "{$params['library']}.{$controller}";
             }
         }
         $values = compact('controller');
     }
     $values += $params;
     if (is_callable($rules)) {
         $rules = $rules($params);
     }
     foreach ($rules as $rule => $value) {
         if (!isset($values[$rule])) {
             continue;
         }
         foreach ($value as $k => $v) {
             if (is_callable($v)) {
                 $values[$k] = $v($values);
                 continue;
             }
             $match = preg_replace('/\\{:\\w+\\}/', '@', $v);
             $match = preg_replace('/@/', '.+', preg_quote($match, '/'));
             if (preg_match('/' . $match . '/i', $values[$k])) {
                 continue;
             }
             $values[$k] = String::insert($v, $values);
         }
     }
     return $values;
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:53,代码来源:Dispatcher.php


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