From Doctrine comments: Pluralize & Singularize implementation are borrowed from CakePHP with some modifications.
 public static function module($module)
 {
     $module = Inflector::pluralize($module);
     return new static($module);
 }
예제 #2
0
파일: Style.php 프로젝트: phogl/autoloader
 protected function _generateArray(Type $parameter)
 {
     $type = $parameter->getComplexType() ? 'ns:' : 'xsd:';
     $typesComplex = new TypesComplex();
     $typesComplex->setName('ArrayOf' . ucfirst($parameter->getName()))->setArrayType($type . $this->_getObjectName($parameter) . '[]')->setArrayTypeName(Inflector::singularize($parameter->getName()));
     if ($parameter->getComplexType()) {
         $typesComplex->setComplex($this->_generateObject($parameter->getComplexType()));
     }
     return $typesComplex;
 }
예제 #3
0
 /**
  * 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');
 }
예제 #4
0
 private function prepareResourceControllerName()
 {
     $parts = explode('_', $this->controller);
     if (in_array($this->action, array('index', 'create'))) {
         $suffix = array_pop($parts);
     } else {
         $suffix = Inflector::singularize(array_pop($parts));
     }
     $parts[] = $suffix;
     return implode('_', $parts);
 }
 public static function createModule($moduleName)
 {
     $moduleName = ucfirst(Inflector::singularize($moduleName));
     $moduleName = Strings::appendPrefix($moduleName, '\\SugarClient\\Module\\');
     return new $moduleName();
 }
예제 #6
0
 private function classNameFromTableName()
 {
     $parts = explode('_', $this->tableName);
     $parts = $this->removeTablePrefix($parts);
     $parts[] = Inflector::singularize(array_pop($parts));
     $parts = Arrays::map($parts, 'ucfirst');
     return implode('', $parts);
 }
예제 #7
0
 /**
  * @return string
  */
 public function getNameForObject()
 {
     return Inflector::singularize(ucfirst($this->getSanitizedName()));
 }
예제 #8
0
 public static function getModuleName()
 {
     $reflectionClass = new ReflectionClass(get_called_class());
     return Inflector::pluralize($reflectionClass->getShortName());
 }