<commit_before><?php

require_once 'Swat/SwatObject.php';
require_once 'Swat/exceptions/SwatException.php';

/**
 * Information for formatting numeric values
 *
 * @package   SwatI18N
 * @copyright 2007 silverorange
 * @license   http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
 * @see       SwatLocale::formatNumber()
 * @see       SwatLocale::getNumberFormat()
 */
class SwatI18NNumberFormat extends SwatObject
{
	// {{{ public properties

	/**
	 * Decimal point character
	 *
	 * @var string
	 */
	public $decimal_separator;

	/**
	 * Thousands separator
	 *
	 * @var string
	 */
	public $thousands_separator;

	/**
	 * Numeric groupings
	 *
	 * @var array
	 */
	public $grouping;

	/**
	 * Positive sign
	 *
	 * @var string
	 */
	public $p_sign;

	/**
	 * Negative sign
	 *
	 * @var string
	 */
	public $n_sign;

	// }}}
	// {{{ public function override()

	/**
	 * Gets a new number format object with certain properties overridden from
	 * specified values
	 *
	 * The override information is specified as an associative array with
	 * array keys representing property names of this formatting object and
	 * array values being the overridden values.
	 *
	 * For example, to override the positive and negative signs of this format,
	 * use:
	 * <code>
	 * <?php
	 * $format->override(array('n_sign' => 'neg', 'p_sign' => 'pos'));
	 * ?>
	 * </code>
	 *
	 * @param array $format the format information with which to override thss
	 *                       format.
	 *
	 * @return SwatI18NNumberFormat a copy of this number format with the
	 *                               specified properties set to the new values.
	 *
	 * @throws SwatException if any of the array keys do not match a formatting
	 *                       property of this property.
	 */
	public function override(array $format)
	{
		$reflector = new ReflectionObject($this);

		foreach ($format as $key => $value) {
			if (!$reflector->hasProperty($key)) {
				throw new SwatException("Number formatting information ".
					"contains invalid property {$key} and cannot override ".
					"this number format.");
			}
		}

		$new_format = clone $this;<commit_msg>This is 150 times faster and does the same thing.<commit_after><?php

require_once 'Swat/SwatObject.php';
require_once 'Swat/exceptions/SwatException.php';

/**
 * Information for formatting numeric values
 *
 * @package   SwatI18N
 * @copyright 2007 silverorange
 * @license   http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
 * @see       SwatLocale::formatNumber()
 * @see       SwatLocale::getNumberFormat()
 */
class SwatI18NNumberFormat extends SwatObject
{
	// {{{ public properties

	/**
	 * Decimal point character
	 *
	 * @var string
	 */
	public $decimal_separator;

	/**
	 * Thousands separator
	 *
	 * @var string
	 */
	public $thousands_separator;

	/**
	 * Numeric groupings
	 *
	 * @var array
	 */
	public $grouping;

	/**
	 * Positive sign
	 *
	 * @var string
	 */
	public $p_sign;

	/**
	 * Negative sign
	 *
	 * @var string
	 */
	public $n_sign;

	// }}}
	// {{{ public function override()

	/**
	 * Gets a new number format object with certain properties overridden from
	 * specified values
	 *
	 * The override information is specified as an associative array with
	 * array keys representing property names of this formatting object and
	 * array values being the overridden values.
	 *
	 * For example, to override the positive and negative signs of this format,
	 * use:
	 * <code>
	 * <?php
	 * $format->override(array('n_sign' => 'neg', 'p_sign' => 'pos'));
	 * ?>
	 * </code>
	 *
	 * @param array $format the format information with which to override thss
	 *                       format.
	 *
	 * @return SwatI18NNumberFormat a copy of this number format with the
	 *                               specified properties set to the new values.
	 *
	 * @throws SwatException if any of the array keys do not match a formatting
	 *                       property of this property.
	 */
	public function override(array $format)
	{
		$vars = get_object_vars($this);

		foreach ($format as $key => $value) {
			if (!array_key_exists($key, $vars)) {
				throw new SwatException("Number formatting information ".
					"contains invalid property {$key} and cannot override ".
					"this number format.");
			}
		}

		$new_format = clone $this;
{'fraction_non_alphanumeric': 0.11178107606679036, 'fraction_numerical': 0.006261595547309833, 'mean_word_length': 2.796654929577465, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4419119', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1202, 'n_words': 412}