<?php
 namespace App\Support; class MergeFieldDictionary { public const CANONICAL = [ 'CLIENT_NAME', 'FIRSTNAME', 'LASTNAME', 'EMAIL', 'COMPANY_NAME', 'SITE_URL', 'SIGNATURE', 'CURRENT_DATE', 'INVOICE_NUMBER', 'INVOICE_TOTAL', 'DUE_DATE', 'INVOICE_URL', 'PAYMENT_METHOD', 'AMOUNT', 'CURRENCY', 'ORDER_NUMBER', 'ORDER_TOTAL', 'ORDER_URL', 'TICKET_ID', 'TICKET_SUBJECT', 'TICKET_DEPARTMENT', 'TICKET_URL', 'DOMAIN_NAME', 'EXPIRY_DATE', 'NAMESERVERS', 'SERVICE_NAME', 'SERVICE_DOMAIN', 'NEXT_DUE_DATE', 'QUOTE_NUMBER', 'QUOTE_TOTAL', 'QUOTE_URL', 'COMMISSION_AMOUNT', 'PAYOUT_AMOUNT', 'STATUS', 'REASON', 'SUBJECT', 'MESSAGE', ]; public const ALIASES = [ 'CLIENTID' => 'CLIENT_ID', 'CLIENTEMAIL' => 'CLIENT_EMAIL', 'COMPANY' => 'COMPANY_NAME', 'COMPANYNAME' => 'COMPANY_NAME', 'FIRST_NAME' => 'FIRSTNAME', 'LAST_NAME' => 'LASTNAME', 'INVOICEID' => 'INVOICE_ID', 'INVOICENUM' => 'INVOICE_NUMBER', 'INVOICENUMBER' => 'INVOICE_NUMBER', 'INVOICE_NUM' => 'INVOICE_NUMBER', 'INVOICEDATE' => 'INVOICE_DATE', 'INVOICETOTAL' => 'INVOICE_TOTAL', 'INVOICESTATUS' => 'INVOICE_STATUS', 'INVOICEURL' => 'INVOICE_URL', 'DUEDATE' => 'DUE_DATE', 'RECEIPTURL' => 'RECEIPT_URL', 'PAYMENTDATE' => 'PAYMENT_DATE', 'PAYMENTMETHOD' => 'PAYMENT_METHOD', 'PAYMENTAMOUNT' => 'PAYMENT_AMOUNT', 'ORDERID' => 'ORDER_ID', 'ORDERNUMBER' => 'ORDER_NUMBER', 'ORDERDATE' => 'ORDER_DATE', 'ORDERTOTAL' => 'ORDER_TOTAL', 'ORDERSTATUS' => 'ORDER_STATUS', 'ORDERURL' => 'ORDER_URL', 'TICKETID' => 'TICKET_ID', 'TICKETNUMBER' => 'TICKET_NUMBER', 'TICKETSUBJECT' => 'TICKET_SUBJECT', 'TICKETSTATUS' => 'TICKET_STATUS', 'TICKETPRIORITY' => 'TICKET_PRIORITY', 'TICKETDEPARTMENT' => 'TICKET_DEPARTMENT', 'TICKETURL' => 'TICKET_URL', 'TICKETMESSAGE' => 'TICKET_MESSAGE', 'DOMAINID' => 'DOMAIN_ID', 'DOMAINNAME' => 'DOMAIN_NAME', 'DOMAINTLD' => 'DOMAIN_TLD', 'DOMAINSTATUS' => 'DOMAIN_STATUS', 'DOMAINURL' => 'DOMAIN_URL', 'DOMAINEXPIRYDATE' => 'DOMAIN_EXPIRY_DATE', 'DOMAINREGISTRATIONDATE' => 'DOMAIN_REGISTRATION_DATE', 'EXPIRYDATE' => 'EXPIRY_DATE', 'REGISTRATIONDATE' => 'REGISTRATION_DATE', 'RENEWALDATE' => 'RENEWAL_DATE', 'NEWEXPIRYDATE' => 'NEW_EXPIRY_DATE', 'RENEWALPERIOD' => 'RENEWAL_PERIOD', 'VERIFICATIONCODE' => 'VERIFICATION_CODE', 'VERIFICATIONURL' => 'VERIFICATION_URL', 'EXPIRESMINUTES' => 'EXPIRES_MINUTES', 'EXPIRESAT' => 'EXPIRES_AT', 'RESETCODE' => 'RESET_CODE', 'RESETURL' => 'RESET_URL', 'INVITELINK' => 'INVITE_LINK', 'SERVICENAME' => 'SERVICE_NAME', 'BONUSAMOUNT' => 'BONUS_AMOUNT', 'MAINTENANCETIME' => 'MAINTENANCE_TIME', 'ALERTMESSAGE' => 'ALERT_MESSAGE', 'ALERTTYPE' => 'ALERT_TYPE', 'BILLINGURL' => 'BILLING_URL', 'CARDEXPIRY' => 'CARD_EXPIRY', 'SSLSTARTDATE' => 'SSL_START_DATE', 'SSLENDDATE' => 'SSL_END_DATE', 'SSLTYPE' => 'SSL_TYPE', 'CPANELUSERNAME' => 'CPANEL_USERNAME', 'CPANELPASSWORD' => 'CPANEL_PASSWORD', 'CPANELURL' => 'CPANEL_URL', 'CANCELLATIONID' => 'CANCELLATION_ID', 'CANCELLATIONREASON' => 'CANCELLATION_REASON', 'REQUESTDATE' => 'REQUEST_DATE', 'ADMINNAME' => 'ADMIN_NAME', 'ADMINEMAIL' => 'ADMIN_EMAIL', 'ADMINORDERURL' => 'ADMIN_ORDER_URL', 'ADMINCANCELLATIONURL' => 'ADMIN_CANCELLATION_URL', 'REPLYID' => 'REPLY_ID', 'REPLYDATE' => 'REPLY_DATE', 'REPLYTIME' => 'REPLY_TIME', ]; public static function expand(array $fields): array { static $reverse = null; if ($reverse === null) { $reverse = []; foreach (self::ALIASES as $alias => $canonical) { $reverse[$canonical][] = $alias; } } $expanded = $fields; foreach ($fields as $key => $value) { if (isset(self::ALIASES[$key])) { $canonical = self::ALIASES[$key]; if (! array_key_exists($canonical, $expanded)) { $expanded[$canonical] = $value; } } if (isset($reverse[$key])) { foreach ($reverse[$key] as $alias) { if (! array_key_exists($alias, $expanded)) { $expanded[$alias] = $value; } } } } return $expanded; } } 