Ejemplo n.º 1
0
     */
    public static function variable($string)
    {
        if (!($result = self::_cache(__FUNCTION__, $string))) {
            $camelized = Inflector::camelize(Inflector::underscore($string));
            $replace = strtolower(substr($camelized, 0, 1));
            $result = preg_replace('/\\w/', $replace, $camelized, 1);
            self::_cache(__FUNCTION__, $string, $result);
        }
        return $result;
    }
    /**
     * Returns a string with all spaces converted to underscores (by default), accented
     * characters converted to non-accented characters, and non word characters removed.
     *
     * @param string $string the string you want to slug
     * @param string $replacement will replace keys in map
     * @return string
     * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::slug
     */
    public static function slug($string, $replacement = '_')
    {
        $quotedReplacement = preg_quote($replacement, '/');
        $merge = array('/[^\\s\\p{Zs}\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nd}]/mu' => ' ', '/[\\s\\p{Zs}]+/mu' => $replacement, sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '');
        $map = self::$_transliteration + $merge;
        return preg_replace(array_keys($map), array_values($map), $string);
    }
}
// Store the initial state
Inflector::reset();
Ejemplo n.º 2
0
 public function tearDown()
 {
     Inflector::reset();
 }
Ejemplo n.º 3
0
/**
 * teardown
 *
 * @return void
 */
	public function tearDown() {
		parent::tearDown();
		Inflector::reset();
	}
Ejemplo n.º 4
0
 /**
  * Delete created objects from the database, clear defined
  * blueprints, and clear stored inflection exceptions.
  */
 public function reset()
 {
     $this->recall();
     $this->_blueprints = [];
     Inflector::reset();
 }