<commit_before>
/*
 +------------------------------------------------------------------------+
 | Phalcon Framework                                                      |
 +------------------------------------------------------------------------+
 | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com)       |
 +------------------------------------------------------------------------+
 | This source file is subject to the New BSD License that is bundled     |
 | with this package in the file docs/LICENSE.txt.                        |
 |                                                                        |
 | If you did not receive a copy of the license and are unable to         |
 | obtain it through the world-wide-web, please send an email             |
 | to <EMAIL> so we can send you a copy immediately.       |
 +------------------------------------------------------------------------+
 | Authors: <NAME> <<EMAIL>>                      |
 |          <NAME> <<EMAIL>>                         |
 +------------------------------------------------------------------------+
 */

namespace Phalcon;

/**
 * Phalcon\Text
 *
 * Provides utilities to work with texts
 */
abstract class Text
{

	const RANDOM_ALNUM = 0;

	const RANDOM_ALPHA = 1;

	const RANDOM_HEXDEC = 2;

	const RANDOM_NUMERIC = 3;

	const RANDOM_NOZERO = 4;

	/**
	 * Converts strings to camelize style
	 *
	 *<code>
	 *      echo Phalcon\Text::camelize('coco_bongo'); //CocoBongo
	 *</code>
	 *
	 * @param string str
	 * @return string
	 */
	static public function camelize(string str) -> string
	{
		return str->camelize();
	}

	/**
	 * Uncamelize strings which are camelized
	 *
	 *<code>
	 *      echo Phalcon\Text::camelize('CocoBongo'); //coco_bongo
	 *</code>
	 *
	 * @param string str
	 * @return string
	 */
	static public function uncamelize(string str) -> string
	{
		return str->uncamelize();
	}

	/**
	 * Adds a number to a string or increment that number if it already is defined
	 *
	 *<code>
	 *	echo Phalcon\Text::increment("a"); // "a_1"
	 *	echo Phalcon\Text::increment("a_1"); // "a_2"
	 *</code>
	 *
	 * @param string $str
	 * @param string $separator
	 * @return string
	 */
	static public function increment(string str, var separator = null)
	{
		var parts, number;

		if separator === null {
			let separator = "_";
		}

		let parts = explode(separator, str);

		if fetch number, parts[1] {
			let number++;
		} else {
			let number = 1;
		}

		return parts[0] . separator. number;
	}

	/**
	 * Generates a random string based on the given type. Type is one of the RANDOM_* constants
	 *
	 *<code>
	 *	echo Phalcon\Text::random(Phalcon\Text::RANDOM_ALNUM); //"aloiwkqz"
	 *</code>
	 *
	 * @param int type
	 * @param int length
	 * @return string
	 */
	static public function random(int type = 0, long length = 8) -> string<commit_msg>Fixes to Phalcon\Text<commit_after>
/*
 +------------------------------------------------------------------------+
 | Phalcon Framework                                                      |
 +------------------------------------------------------------------------+
 | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com)       |
 +------------------------------------------------------------------------+
 | This source file is subject to the New BSD License that is bundled     |
 | with this package in the file docs/LICENSE.txt.                        |
 |                                                                        |
 | If you did not receive a copy of the license and are unable to         |
 | obtain it through the world-wide-web, please send an email             |
 | to <EMAIL> so we can send you a copy immediately.       |
 +------------------------------------------------------------------------+
 | Authors: <NAME> <<EMAIL>>                      |
 |          <NAME> <<EMAIL>>                         |
 +------------------------------------------------------------------------+
 */

namespace Phalcon;

/**
 * Phalcon\Text
 *
 * Provides utilities to work with texts
 */
abstract class Text
{

	const RANDOM_ALNUM = 0;

	const RANDOM_ALPHA = 1;

	const RANDOM_HEXDEC = 2;

	const RANDOM_NUMERIC = 3;

	const RANDOM_NOZERO = 4;

	/**
	 * Converts strings to camelize style
	 *
	 *<code>
	 *      echo Phalcon\Text::camelize('coco_bongo'); //CocoBongo
	 *</code>
	 *
	 * @param string str
	 * @return string
	 */
	static public function camelize(string str) -> string
	{
		return str->camelize();
	}

	/**
	 * Uncamelize strings which are camelized
	 *
	 *<code>
	 *      echo Phalcon\Text::camelize('CocoBongo'); //coco_bongo
	 *</code>
	 *
	 * @param string str
	 * @return string
	 */
	static public function uncamelize(string str) -> string
	{
		return str->uncamelize();
	}

	/**
	 * Adds a number to a string or increment that number if it already is defined
	 *
	 *<code>
	 *	echo Phalcon\Text::increment("a"); // "a_1"
	 *	echo Phalcon\Text::increment("a_1"); // "a_2"
	 *</code>
	 *
	 * @param string $str
	 * @param string $separator
	 * @return string
	 */
	static public function increment(string str, var separator = null) -> string
	{
		var parts, number;

		if separator === null {
			let separator = "_";
		}

		let parts = explode(separator, str);

		if fetch number, parts[1] {
			let number++;
		} else {
			let number = 1;
		}

		return parts[0] . separator. number;
	}

	/**
	 * Generates a random string based on the given type. Type is one of the RANDOM_* constants
	 *
	 *<code>
	 *	echo Phalcon\Text::random(Phalcon\Text::RANDOM_ALNUM); //"aloiwkqz"
	 *</code>
	 *
	 * @param int type
	 * @param int length
	 * @return string
	 */
	static public function random(int type = 0, long length = 8) -> string
{'fraction_non_alphanumeric': 0.2329366468323416, 'fraction_numerical': 0.007350367518375919, 'mean_word_length': 1.4517374517374517, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2708075', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1561, 'n_words': 490}