<commit_before><?php

/**
 *
 * Abstract Request object containing common methods and variables for API-specific request objects
 *
 * @package    AGMS
 * @subpackage Request
 * @copyright  2014 Avant-Garde Marketing Solutions, Inc.
 * 
 **/

namespace Agms\Request;

abstract class Request 
{

	/************ Object Variables ************/
	protected $validateErrors = -1;
	protected $validateMessages;

	protected $op;
	protected $fields;

	// Placeholders to prevent undefined errors
	protected $required;
	protected $numeric;
	protected $optionable;
	protected $enums;
	protected $date;
	protected $time;
	protected $boolean;
	protected $state;
	protected $amount;

	protected $needsAccount;
	protected $needsKey;

	// Friendly fieldname mapping
	protected static $mapping_alias;
	protected static $mapping = array(
		'gateway_username' => 'GatewayUserName',
		'gateway_password' => '<PASSWORD>',
		'gateway_account' => 'AccountNumber',
		'gateway_key' => 'TransactionAPIKey',
		'amount' => 'Amount',
		'description' => 'OrderDescription',
		'order_description' => 'OrderDescription',
		'return_url' => 'RetURL',
		'enable_ach' => 'ACHEnabled',
		'transaction_type' => 'TransactionType',
		'payment_type' => 'PaymentType',
		'enable_auto_add_to_safe' => 'AutoSAFE',
		'processing_account_id' => 'ProcessorID',
		'enable_donation' => 'Donation',
		'max_link_uses' => 'UsageCount',
		'cc_number' => 'CCNumber',
		'cc_exp_date' => 'CCExpDate',
		'cc_cvv' => 'CVV',
		'cc_track_1' => 'Track1',
		'cc_track_2' => 'Track2',
		'cc_track_3' => 'Track3',
		'cc_encrypted_data' => 'MagData',
		'cc_encrypted_hardware' => 'MagHardware',
		'ach_name' => 'CheckName',
		'ach_routing_number' => 'CheckABA',
		'ach_account_number' => 'CheckAccount',
		'ach_business_or_personal' => 'AccountHolderType',
		'ach_checking_or_savings' => 'AccountType',
		'ach_sec_code' => 'SecCode',
		'safe_action' => 'SAFE_Action',
		'safe_id' => 'SAFE_ID',
		'first_name' => 'FirstName',
		'last_name' => 'LastName',
		'company_name' => 'Company',
		'company' => 'Company',
		'address' => 'Address1',
		'address_1' => 'Address1',
		'address_2' => 'Address2',
		'city' => 'City',
		'state' => 'State',
		'zip' => 'Zip',
		'country' => 'Country',
		'phone' => 'Phone',
		'fax' => 'Fax',
		'email' => 'EMail',
		'website' => 'Website',
		'tax_amount' => 'Tax',
		'shipping_amount' => 'Shipping',
		'tip_amount' => 'TipAmount',
		'order_id' => 'OrderID',
		'po_number' => 'PONumber',
		'clerk_id' => 'ClerkID',
		'ip_address' => 'IPAddress',
		'receipt_type' => 'ReceiptType',
		'shipping_first_name' => 'ShippingFirstName',
		'shipping_last_name' => 'ShippingLastName',
		'shipping_company_name' => 'ShippingCompany',
		'shipping_company' => 'ShippingCompany',
		'shipping_address' => 'ShippingAddress1',
		'shipping_address_1' => 'ShippingAddress1',
		'shipping_address_2' => 'ShippingAddress2',
		'shipping_city' => 'ShippingCity',
		'shipping_state' => 'ShippingState',
		'shipping_zip' => 'ShippingZip',
		'shipping_country' => 'ShippingCountry',
		'shipping_email' => 'ShippingEmail',
		'shipping_phone' => 'ShippingPhone',
		'shipping_fax' => 'ShippingFax',
		'shipping_tracking_number' => 'ShippingTrackingNumber',
		'shipping_carrier' => 'ShippingCarrier',
		'custom_field_1' => 'Custom_Field_1',
		'custom_field_2' => 'Custom_Field_2',
		'custom_field_3' => 'Custom_Field_3',
		'custom_field_4' => 'Custom_Field_4',
		'custom_field_5' => 'Custom_Field_5',
		'custom_field_6' => 'Custom_Field_6',
		'custom_field_7' => 'Custom_Field_7',
		'custom_field_8' => 'Custom_Field_8',
		'custom_field_9' => 'Custom_Field_9',
		'custom_field_10' => 'Custom_Field_10',
		'start_date' => 'StartDate',
		'end_date' => 'EndDate',
		'expiring_in_30_days' => 'Expiring30',
		'recurring_id' => 'RecurringID',
		'merchant_id' => 'MerchantID',
		'initial_amount' => 'InitialAmount',
		'recurring_amount' => 'RecurringAmount',
		'frequency' => 'Frequency',
		'quantity' => 'Quantity',
		'number_of_times_to_bill' => 'NumberOfOccurrences',
		'number_of_retries' => 'NumberOfRetries',
		'hpp_format' => 'HPPFormat',
		'cc_last_4' => 'CreditCardLast4',
		'transaction_id' => 'TransactionID',
		'start_time' => 'StartTime',
		'end_time' => 'EndTime',
		'suppress_safe_option' => 'SupressAutoSAFE',
	);


	/************ Constructor ************/
	public function __construct($op) 
	{

		$this->op = $op;

		for ($i = 1; $i <= 10; $i++) {

		    $constant_name = 'Custom_Name_' . $i;

			// Verify that custom fieldnames don't impose on any reserved keywords
		    if (\Agms\Request\Request::checkForName(\Agms\Utility\Settings::$$constant_name))
		        throw new \Agms\Exception\ConfigurationException('Invalid custom field name "' . \Agms\Utility\Settings::$$constant_name . '" for ' . $constant_name . ', this is a reserved name and cannot be used.');
		    else
				self::$mapping_alias[\Agms\Utility\Settings::$$constant_name] = 'Custom_Field_' . $i;

		}

	} // constructor()


	/************ Static Functions ************/
	// Used by Agms.php initialization to verify that custom fields don't collide with reserved names
	public static function checkForName($name) 
	{

		if (array_key_exists($name, self::$mapping))
			return true;
		else
			return false;

	} // checkForName()

<commit_msg>Fixed issue with static class variables not resetting as expected<commit_after><?php

/**
 *
 * Abstract Request object containing common methods and variables for API-specific request objects
 *
 * @package    AGMS
 * @subpackage Request
 * @copyright  2014 Avant-Garde Marketing Solutions, Inc.
 * 
 **/

namespace Agms\Request;

abstract class Request 
{

	/************ Object Variables ************/
	protected $validateErrors = -1;
	protected $validateMessages;

	protected $op;
	protected $fields;

	// Placeholders to prevent undefined errors
	protected $required;
	protected $numeric;
	protected $optionable;
	protected $enums;
	protected $date;
	protected $time;
	protected $boolean;
	protected $state;
	protected $amount;

	protected $needsAccount;
	protected $needsKey;

	// Friendly fieldname mapping
	protected static $mapping_alias;
	protected static $mapping;
	protected static $mapping_master = array(
		'gateway_username' => 'GatewayUserName',
		'gateway_password' => 'GatewayPassword',
		'gateway_account' => 'AccountNumber',
		'gateway_key' => 'TransactionAPIKey',
		'amount' => 'Amount',
		'description' => 'OrderDescription',
		'order_description' => 'OrderDescription',
		'return_url' => 'RetURL',
		'enable_ach' => 'ACHEnabled',
		'transaction_type' => 'TransactionType',
		'payment_type' => 'PaymentType',
		'enable_auto_add_to_safe' => 'AutoSAFE',
		'processing_account_id' => 'ProcessorID',
		'enable_donation' => 'Donation',
		'max_link_uses' => 'UsageCount',
		'cc_number' => 'CCNumber',
		'cc_exp_date' => 'CCExpDate',
		'cc_cvv' => 'CVV',
		'cc_track_1' => 'Track1',
		'cc_track_2' => 'Track2',
		'cc_track_3' => 'Track3',
		'cc_encrypted_data' => 'MagData',
		'cc_encrypted_hardware' => 'MagHardware',
		'ach_name' => 'CheckName',
		'ach_routing_number' => 'CheckABA',
		'ach_account_number' => 'CheckAccount',
		'ach_business_or_personal' => 'AccountHolderType',
		'ach_checking_or_savings' => 'AccountType',
		'ach_sec_code' => 'SecCode',
		'safe_action' => 'SAFE_Action',
		'safe_id' => 'SAFE_ID',
		'first_name' => 'FirstName',
		'last_name' => 'LastName',
		'company_name' => 'Company',
		'company' => 'Company',
		'address' => 'Address1',
		'address_1' => 'Address1',
		'address_2' => 'Address2',
		'city' => 'City',
		'state' => 'State',
		'zip' => 'Zip',
		'country' => 'Country',
		'phone' => 'Phone',
		'fax' => 'Fax',
		'email' => 'EMail',
		'website' => 'Website',
		'tax_amount' => 'Tax',
		'shipping_amount' => 'Shipping',
		'tip_amount' => 'TipAmount',
		'order_id' => 'OrderID',
		'po_number' => 'PONumber',
		'clerk_id' => 'ClerkID',
		'ip_address' => 'IPAddress',
		'receipt_type' => 'ReceiptType',
		'shipping_first_name' => 'ShippingFirstName',
		'shipping_last_name' => 'ShippingLastName',
		'shipping_company_name' => 'ShippingCompany',
		'shipping_company' => 'ShippingCompany',
		'shipping_address' => 'ShippingAddress1',
		'shipping_address_1' => 'ShippingAddress1',
		'shipping_address_2' => 'ShippingAddress2',
		'shipping_city' => 'ShippingCity',
		'shipping_state' => 'ShippingState',
		'shipping_zip' => 'ShippingZip',
		'shipping_country' => 'ShippingCountry',
		'shipping_email' => 'ShippingEmail',
		'shipping_phone' => 'ShippingPhone',
		'shipping_fax' => 'ShippingFax',
		'shipping_tracking_number' => 'ShippingTrackingNumber',
		'shipping_carrier' => 'ShippingCarrier',
		'custom_field_1' => 'Custom_Field_1',
		'custom_field_2' => 'Custom_Field_2',
		'custom_field_3' => 'Custom_Field_3',
		'custom_field_4' => 'Custom_Field_4',
		'custom_field_5' => 'Custom_Field_5',
		'custom_field_6' => 'Custom_Field_6',
		'custom_field_7' => 'Custom_Field_7',
		'custom_field_8' => 'Custom_Field_8',
		'custom_field_9' => 'Custom_Field_9',
		'custom_field_10' => 'Custom_Field_10',
		'start_date' => 'StartDate',
		'end_date' => 'EndDate',
		'expiring_in_30_days' => 'Expiring30',
		'recurring_id' => 'RecurringID',
		'merchant_id' => 'MerchantID',
		'initial_amount' => 'InitialAmount',
		'recurring_amount' => 'RecurringAmount',
		'frequency' => 'Frequency',
		'quantity' => 'Quantity',
		'number_of_times_to_bill' => 'NumberOfOccurrences',
		'number_of_retries' => 'NumberOfRetries',
		'hpp_format' => 'HPPFormat',
		'cc_last_4' => 'CreditCardLast4',
		'transaction_id' => 'TransactionID',
		'start_time' => 'StartTime',
		'end_time' => 'EndTime',
		'suppress_safe_option' => 'SupressAutoSAFE',
	);


	/************ Constructor ************/
	public function __construct($op) 
	{

		$this->op = $op;
		self::$mapping = self::$mapping_master;

		for ($i = 1; $i <= 10; $i++) {

		    $constant_name = 'Custom_Name_' . $i;

			// Verify that custom fieldnames don't impose on any reserved keywords
		    if (\Agms\Request\Request::checkForName(\Agms\Utility\Settings::$$constant_name))
		        throw new \Agms\Exception\ConfigurationException('Invalid custom field name "' . \Agms\Utility\Settings::$$constant_name . '" for ' . $constant_name . ', this is a reserved name and cannot be used.');
		    else
				self::$mapping_alias[\Agms\Utility\Settings::$$constant_name] = 'Custom_Field_' . $i;

		}

	} // constructor()


	/************ Static Functions ************/
	// Used by Agms.php initialization to verify that custom fields don't collide with reserved names
	public static function checkForName($name) 
	{

		if (array_key_exists($name, self::$mapping))
			return true;
		else
			return false;

	} // checkForName()


{'fraction_non_alphanumeric': 0.18019541525742203, 'fraction_numerical': 0.00977076287110109, 'mean_word_length': 5.171014492753623, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 200, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2461330', 'n_tokens_mistral': 4073, 'n_tokens_neox': 3762, 'n_words': 714}