@param bool $letters
@param bool $digits
@param int $length
@param bool $capitalization
@param bool $alternation
@param string $symbol_string

@return $this
966693
public function setRandomGenerator(bool $letters = true, bool $digits = false, int $length = 16, bool $capitalization = false, bool $alternation = true, string $symbol_string = '')
    {
        if (abs($length) < 6) {
            $length = 16;
        }

        ob_start();
        ?>
        <script>
            function random_for_input() {
                var res = '', i = 0;
                <?php if ($alternation): ?>
                    var v = 'eyuioa', c = 'qwrtpsdfghjklzxcvbnm', vl = v.length - 1, cl = c.length - 1, change = false;

                    for (; i < <?=$length?>; i++) {
                        res += change ? v.charAt(rand(0, vl)) : c.charAt(rand(0, cl));
                        change = !change;
                    }
                <?php else: ?>
                    var s = '<?= $symbol_string ? $symbol_string : (($letters ? 'qertyupasdfkzxcvbnm' : '') . ($capitalization ? 'QERTYUPASDFKZXCVBNM' : '') . ($digits ? '123456789' : '')) ?>';

                    var sl = s.length - 1;

                    for (; i < <?=$length?>; i++) {
                        res += s.charAt(rand(0, sl));
                    }
                <?php endif; ?>
                return res;
            }
        </script>
        <?php

        $this->js_function_for_random = ob_get_clean();

        return $this;
    }
555433
private function parse_diacritics_rules( array $diacritics_rules, array &$patterns, array &$replacements ) {

		foreach ( $diacritics_rules as $needle => $replacement ) {
			$patterns[]              = '/\b(?<!\w[' . U::NO_BREAK_SPACE . U::SOFT_HYPHEN . '])' . $needle . '\b(?![' . U::NO_BREAK_SPACE . U::SOFT_HYPHEN . ']\w)/u';
			$replacements[ $needle ] = $replacement;
		}
	}
1013198
private function doTransitionFromD() : self
    {
        if ($this->getToken() === Grammar::T_L) {
            $this
                ->setState(self::STATE_C)
                ->addPosition(1)
                ->addTokenValue(Grammar::T_L);
            return $this;
        }

        if ($this->getToken() === Grammar::T_X && $this->hasToken(1) && $this->getToken(1) === Grammar::T_L) {
            $this
                ->setState(self::STATE_B)
                ->addPosition(2)
                ->addTokenValue(Grammar::T_L, Grammar::T_X);
            return $this;
        }

        if ($this->getToken() === Grammar::T_X && $this->hasToken(1) && $this->getToken(1) === Grammar::T_C) {
            $this
                ->setState(self::STATE_B)
                ->addPosition(2)
                ->addTokenValue(Grammar::T_C, Grammar::T_X);
            return $this;
        }

        $this->setState(self::STATE_C);
        return $this;
    }
706555
public function create($ifNotExists = false, $charset = 'utf8')
    {
        if ($ifNotExists && $this->exists()) {
            return $this;
        }

        $query = PostgresqlGrammar::createDatabase($this->name, $charset);

        $this->db->setQuery($query)->execute();

        return $this;
    }
10443
public function symbols($currencies = null)
    {
        if (func_num_args() and !is_array(func_get_args()[0])) {
            $currencies = func_get_args();
        }

        $this->symbols = $currencies;

        return $this;
    }
906705
protected function mergeConcatenatedStrings()
	{
		if ($this->tokens[$this->i - 1][0]    !== T_CONSTANT_ENCAPSED_STRING
		 || $this->tokens[$this->i + 1][0]    !== T_CONSTANT_ENCAPSED_STRING
		 || $this->tokens[$this->i - 1][1][0] !== $this->tokens[$this->i + 1][1][0])
		{
			return false;
		}

		// Merge both strings into the right string
		$this->tokens[$this->i + 1][1] = substr($this->tokens[$this->i - 1][1], 0, -1)
		                               . substr($this->tokens[$this->i + 1][1], 1);

		// Unset the tokens that have been optimized away
		unset($this->tokens[$this->i - 1]);
		unset($this->tokens[$this->i]);

		// Advance the cursor
		++$this->i;

		return true;
	}
391200
public function digits($msg)
    {
        if(strlen($this->_value) > 0 && !ctype_digit((string) $this->_value)) {
            $this->_errors[] = $msg;
        }
        return $this;
    }
552753
public function setCharset($charset = null)
    {
        if (! is_null($charset)) {
            $this->charset = $charset;
        } elseif (defined('THEMOSIS_CHARSET')) {
            $this->charset = THEMOSIS_CHARSET;
        } elseif (function_exists('get_bloginfo')) {
            $this->charset = get_bloginfo('charset');
        }

        return $this;
    }
1056211
public function withPrefix($values, string $currency = null, int $decimal_points = null): string
    {
        [$className, $value] = $this->classAndValue($values, $currency);

        return (new $className)->prefix($value, $decimal_points);
    }
255105
public function setCharset($charset)
    {
        $this->charset = $charset;
        if (!$this->headerCharset) {
            $this->headerCharset = $charset;
        }

        return $this;
    }
930420
public static function charNotInAlphabet(string $char) : self
    {
        $ord = \ord($char);

        if ($ord < 32 || $ord > 126) {
            $char = \strtoupper(\dechex($ord));

            if ($ord < 10) {
                $char = '0' . $char;
            }
        } else {
            $char = '"' . $char . '"';
        }

        return new self(sprintf('Char %s is not a valid character in the given alphabet.', $char));
    }
361677
function slugify()
    {
        $text = (string) $this;

        // replace non letter or digits by -
        $text = preg_replace('~[^\pL\d]+~u', '-', $text);

        // transliterate
        $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

        // remove unwanted characters
        $text = preg_replace('~[^-\w]+~', '', $text);

        // trim
        $text = trim($text, '-');

        // remove duplicate -
        $text = preg_replace('~-+~', '-', $text);

        // lowercase
        $text = strtolower($text);

        if (empty($text))
            return 'n-a';

        return new self($text);
    }
126596
public function digits($message = null)
    {
        $this->setRule(__FUNCTION__, function($val)
                       {
                           return (strlen($val) === 0 || ctype_digit((string) $val));
                       }, $message);
        return $this;
    }
509916
static public function underscoreToCamel($str, $capitalise_first_char = false, $space = false)
    {
        if ($capitalise_first_char) {
            $str[0] = strtoupper($str[0]);
        }
        $func = $space ? 'return " " . strtoupper($c[1]);' : 'return strtoupper($c[1]);';
        $callback = create_function('$c', $func);

        return preg_replace_callback('/_([a-z])/', $callback, $str);
    }
438431
function regexp($pattern, $flags = null) {
        $regexp['pattern'] = $pattern;
        if ($flags) $regexp['flags'] = $flags;
        $this->data['regexp'] = $regexp;
        return $this;
    }
52597
function replacePlaceholders(array $symbols, array $replacements = array()) {
    parent::replacePlaceholders($symbols, array(self::SYMBOL_SPECIAL_PERCENT, self::SYMBOL_SPECIAL_PERMILLE));
  }
699943
public function where($cond, $params, $symbol = 'AND')
    {
        if ($cond instanceof \Closure) {
            $this->where[] = '(';
            $cond();
            $this->where[] = ')';
        }
        $this->where[] = [
            $symbol, $cond, is_array($params) ? $params : [$params]
        ];
        return $this;
    }