singularize() публичный статический Метод

Returns a word in singular form.
public static singularize ( string $word ) : string
$word string The word in plural form.
Результат string The word in singular form.
Пример #1
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');
 }
Пример #2
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();
 }
Пример #4
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);
 }
Пример #5
0
 /**
  * @return string
  */
 public function getNameForObject()
 {
     return Inflector::singularize(ucfirst($this->getSanitizedName()));
 }
Пример #6
-1
 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;
 }