Ejemplo n.º 1
0
 /**
  * Test that tableName() returns a plural lower-camel-cased form.
  */
 public function testTableName()
 {
     $this->assertEquals('camelCases', Inflector::tableName('camel Case'));
     $this->assertEquals('studlyCases', Inflector::tableName('StuDly CaSe'));
     $this->assertEquals('titleCases', Inflector::tableName('Title Case'));
     $this->assertEquals('normalCases', Inflector::tableName('Normal case'));
     $this->assertEquals('lowercases', Inflector::tableName('lowercase'));
     $this->assertEquals('uppercases', Inflector::tableName('UPPERCASE'));
     $this->assertEquals('underScores', Inflector::tableName('under_score'));
     $this->assertEquals('dashEs', Inflector::tableName('dash-es'));
     $this->assertEquals('123Numbers', Inflector::tableName('123 numbers'));
     $this->assertEquals('withExtxmls', Inflector::tableName('with EXT.xml'));
     $this->assertEquals('lotsOfWhiteSpaces', Inflector::tableName('lots  of     white space'));
 }
Ejemplo n.º 2
0
 /**
  * Grab any path after /static/ in the URL and use that as the template to render.
  */
 public function index()
 {
     $path = $this->getConfig('path') ?: 'index';
     // Set a page title and render the view using the path
     return $this->getView()->setVariable('pageTitle', Inflector::normalCase(str_replace('/', ' ', $path)))->render('static/' . $path);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public static function tableName($string)
 {
     return static::cache([__METHOD__, $string], function () use($string) {
         return lcfirst(Inflector::camelCase(Inflector::pluralize($string)));
     });
 }
Ejemplo n.º 4
0
 /**
  * Return a slugged version of a string.
  *
  * @param string $string
  * @return string
  */
 public static function slugify($string)
 {
     $string = strip_tags($string);
     $string = str_replace(['&', '&'], 'and', $string);
     $string = str_replace('@', 'at', $string);
     // @codeCoverageIgnoreStart
     if (class_exists('Titon\\G11n\\Utility\\Inflector')) {
         return \Titon\G11n\Utility\Inflector::slug($string);
     }
     // @codeCoverageIgnoreEnd
     return Inflector::slug($string);
 }