本文整理匯總了PHP中Doctrine\Common\Inflector\Inflector::rules方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::rules方法的具體用法?PHP Inflector::rules怎麽用?PHP Inflector::rules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Common\Inflector\Inflector
的用法示例。
在下文中一共展示了Inflector::rules方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testCustomRuleWithReset
/**
* Test resetting inflection rules.
*
* @return void
*/
public function testCustomRuleWithReset()
{
Inflector::reset();
$uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x');
$pluralIrregular = array('as' => 'ases');
Inflector::rules('singular', array('rules' => array('/^(.*)(a|e|o|u)is$/i' => '\\1\\2l'), 'uninflected' => $uninflected), true);
Inflector::rules('plural', array('rules' => array('/^(.*)(a|e|o|u)l$/i' => '\\1\\2is'), 'uninflected' => $uninflected, 'irregular' => $pluralIrregular), true);
$this->assertEquals(Inflector::pluralize('Alcool'), 'Alcoois');
$this->assertEquals(Inflector::pluralize('Atlas'), 'Atlas');
$this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool');
$this->assertEquals(Inflector::singularize('Atlas'), 'Atlas');
}