Misc
in package
Table of Contents
- abbreviateString() : bool|string
- Removes vowels from the string always keeping the first and last letter.
- addKeyPrefix() : array<string|int, mixed>
- Adds prefix to all array keys, mainly for reportings and joining array data together to avoid conflicting keys.
- addSortPrefix() : array<string|int, mixed>
- Adds sort prefixes to an array maintaining the original order. Primarily used because Flex likes to reorded arrays with string keys.
- AdjustXY() : mixed
- APIFileDownload() : bool
- This function helps sending binary data to the client for saving/viewing as a file.
- Array2CSV() : bool|null|string
- Array2JSON() : bool|null|string
- Array2XML() : bool|null|string
- ArrayAssocSum() : array<string|int, mixed>|bool
- This function totals arrays where the data wanting to be totaled is deep in a multi-dimentional array.
- ArrayAvg() : bool|float|int
- arrayChangeValueCase() : array<string|int, mixed>|bool
- Change the case of all values in an array
- arrayColumn() : array<string|int, mixed>|bool|null
- arrayCommonValue() : mixed
- arrayCommonValuesForEachKey() : array<string|int, mixed>|bool
- Returns the most common values for each key (column) in the rows.
- arrayDiffAssocRecursive() : array<string|int, mixed>|bool
- arrayDiffByKey() : array<string|int, mixed>|null
- ArrayGroupBy() : array<string|int, mixed>
- This function is similar to a SQL group by clause, only its done on a AssocArray Pass it a row array just before you send it to smarty.
- arrayIntersectByKey() : array<string|int, mixed>|null
- arrayIntersectByRow() : bool|mixed
- arrayIUnique() : array<string|int, mixed>
- Case insensitive array_unique().
- arrayMergeRecursive() : array<string|int, mixed>
- Merges arrays with overwriting whereas PHP standard array_merge_recursive does not overwrites but combines.
- arrayMergeRecursiveDistinct() : array<string|int, mixed>
- This only merges arrays where the array keys must already exist.
- calculateIncludeExcludeAmount() : int
- calculateMultipleColumns() : bool|int|string
- calculatePercent() : float|int
- censorString() : bool|string
- censor part of a string for purposes of displaying things like SIN, bank accounts, credit card numbers.
- checkValidDomain() : bool
- Checks if the domain the user is seeing in their browser matches the configured domain that should be used.
- checkValidImage() : bool
- cleanDir() : bool
- Delete all files in directory
- compareFloat() : bool
- Compares two float values for equality and greater/less than. Required because floats should never be compared directly due to epsilon differences For example: (float)845.92 + (float)14.3 != (float)860.22 -- Yet it does as far as a human is concerned.
- convertExcelToCSV() : bool
- Converts the first sheet in an Excel file to CSV.
- convertObjectToArray() : array<string|int, mixed>
- countLinesInFile() : int
- decodeInteger() : int
- decrypt() : bool|string
- We can't reliably test that decryption was successful, so type checking should be done in the calling function. (see RemittanceDestinationAccountFactory::getValue3())
- deleteEmptyChildDirectory() : bool
- Deletes all empty directories in $path and underneath (down) from it.
- deleteEmptyParentDirectory() : bool
- Checks to see if the directory $path and $recurse_parent_levels number of parent paths are empty, and deletes them all going *UP* the tree. This will not go *DOWN* the tree.
- detectFileDelimiter() : string|null
- Detects the delimiter of a CSV file (can be semicolon, comma or pipe) by trying every delimiter, then counting how many potential columns could be found with this delimiter and removing the delimiter from array of only one columns could be created (without a working limiter you'll always have "one" column: the entire row).
- detectMobileBrowser() : bool|string
- disableCaching() : bool
- doesRequestExceedPHPMaxPostSize() : bool
- downloadHTTPFile() : bool|int
- encodeInteger() : string
- Encode integer to a alphanumeric value that is reversible.
- encrypt() : bool|string
- escapeCSVTriggerChars() : mixed
- Mititage CSV Injection attacks: See below links for more information: [1] https://www.owasp.org/index.php/CSV_Excel_Macro_Injection [2] https://hackerone.com/reports/72785 [3] https://hackerone.com/reports/90131
- escapeHTML() : array<string|int, mixed>|string
- Sanitizes a string or array of strings against XSS attacks. Used before passing data to HTML emails or back to the user in HTML.
- Export2XML() : mixed
- FileDownloadHeader() : bool
- findClosestMatch() : array<string|int, mixed>|bool|mixed
- Accepts a search_str and key=>val array that it searches through, to return the array key of the closest fuzzy match.
- findSubmitButton() : null|string
- findWebServerOSUser() : bool
- flattenArray() : array<string|int, mixed>
- flattenArrayOneLevel() : array<string|int, mixed>
- Flattens an array by only a single level, ie: [ 'level1' => [ 0 => [ 'key' => 'val' ] ] ] becomes: [ 0 => [ 'key' => 'val' ] ]
- formatAddress() : string
- formatEmailAddress() : string
- formatPhoneNumber() : mixed
- generateCopyName() : bool|string
- generateShareName() : bool|string
- getAfterDecimal() : int
- getAmountAroundLimit() : array<string|int, mixed>|array<string|int, int>
- Returns an adjusted current amount, and the amount under a limit and over a limit.
- getAmountDifferenceToLimit() : string
- This is can be used to handle YTD amounts.
- getAmountToLimit() : int
- getArrayNeighbors() : array<string|int, mixed>
- Uses the internal array pointer to get array neighnors.
- getBeforeDecimal() : int
- getBytesFromSize() : int|string
- getCityAndProvinceAndPostalCode() : string
- getCurrentCompanyProductEdition() : int
- getCurrentOSUser() : bool
- getEmailDomain() : string
- getEmailLocalPart() : string
- getEmailReturnPathLocalPart() : string
- getEnvironmentVariableConfigFile() : string
- Generate a shell command to pass thru the TT_CONFIG_FILE environment variable through to executed cron jobs or system job queue commands.
- getFeatureFlag() : mixed|null
- Returns the value of a specific feature flag, and if none is set returns the default value.
- getFileList() : array<string|int, mixed>|bool
- getFullName() : bool|string
- getHostName() : string
- getHostNameWithoutSubDomain() : string
- getInstanceIdentificationString() : string
- getJSArray() : string
- getMapURL() : bool|string
- getMaxSystemLoad() : mixed
- getMimeType() : bool|mixed|string
- getMobileAppClientVersion() : false|mixed|string
- getPHPMaxUploadSize() : int
- Checks the max post size and file upload size, and returns the lower of the two.
- getPointerFromArray() : mixed
- getRemoteHTTPFileSize() : bool|mixed
- getRemoteIPAddress() : bool
- getSortDirectionArray() : array<string|int, mixed>
- getSystemLoad() : int|mixed
- getSystemMemoryInfo() : int|string
- getUniqueID() : string
- getURLProtocol() : string
- hex2rgb() : array<string|int, mixed>|string
- HumanBoolean() : string
- importApplyColumnMap() : array<string|int, mixed>|bool
- inArrayByKeyAndValue() : bool
- isCurrentOSUserRoot() : bool
- isEmail() : bool
- isJSON() : bool
- isMobileAppUserAgent() : bool
- isOpenPort() : bool
- isPortOpen() : mixed
- isSearchEngineBrowser() : bool
- issetOr() : null
- isSSL() : bool
- isSubDirectory() : bool
- isSystemLoadValid() : bool
- isUnSupportedBrowser() : bool
- isWritable() : bool
- Checks to see if a file/directory is writable.
- MajorVersionCompare() : mixed
- MoneyFormat() : string
- Just a number format that looks like currency without currency symbol can maybe be replaced by TTi18n::numberFormat()
- MoneyRound() : float|int
- Round currency value without formatting it. In most cases where Misc::MoneyFormat( $var, FALSE ) is used, this should be used instead.
- MoneyRoundDifference() : string
- NumberToLetter() : bool|string
- Converts a number between 0 and 25 to the corresponding letter.
- parseCallerID() : bool|string
- Caller ID numbers can come in in all sorts of forms: 2505551234 12505551234 +12505551234 (250) 555-1234 Parse out just the digits, and use only the last 10 digits.
- parseCSV() : array<string|int, mixed>|bool
- parseDatabaseHostString() : array<string|int, mixed>
- parseFeatureFlags() : array<string|int, mixed>
- Returns all parsed feature flags as an array.
- parseMobileAppUserAgent() : false|mixed|string
- parseRFC822EmailAddress() : array<string|int, mixed>|bool
- Parses an RFC822 Email Address ( "John Doe" <john.doe@mydomain.com> ) into its separate components.
- PercentDistribution() : array<string|int, mixed>|bool
- Take an amount and a distribution array of key => value pairs, value being a decimal percent (ie: 0.50 for 50%) return an array with the same keys and resulting distribution between them.
- prependArray() : array<string|int, mixed>|bool
- preSetArrayValues() : array<string|int, mixed>|bool
- This function is used to quickly preset array key => value pairs so we don't have to have so many isset() checks throughout the code.
- redirectMobileBrowser() : bool
- redirectUnSupportedBrowser() : bool
- removeDecimal() : mixed
- removeKeyPrefix() : array<string|int, mixed>|bool
- Removes prefix to all array keys, mainly for reportings and joining array data together to avoid conflicting keys.
- removeTrailingZeros() : string
- value should be a float and not a string. be sure to run this before TTi18n currency or number formatter due to foreign numeric formatting for decimal being a comma.
- rename() : bool
- Renames a file or directory. If rename fails for some reason, attempt a copy instead as that might work, specifically on windows where if the file is in use.
- reScaleRange() : float|int
- Retry() : mixed
- Generic Retry handler with closures.
- sanitizeFileName() : mixed|string|array<string|int, string>|null
- Sanitize strings to be used in file names by converting spaces to underscore and removing non-alpha numeric characters
- sendSystemMail() : bool
- setProcessUID() : bool
- stripDirectoryTraversal() : mixed|string|array<string|int, string>|null
- Removes any sort of directory traversal attacks from a file name, ie: '../../myfile.pdf'
- stripHTMLSpecialChars() : mixed
- Remove any HTML special char (before its encoded) from the string Useful for things like government forms submitted in XML.
- stripPathAndFileNames() : array<string|int, mixed>|string|array<string|int, string>|null
- Strips any mention of path and file names from a string to avoid information exposure vulnerabilities.
- stripThe() : bool|string
- Removes the word "the" from the beginning of strings and optionally places it at the end.
- strReplaceOnce() : mixed
- sumMultipleColumns() : bool|int|string
- Takes an array with columns, and a 2nd array with column names to sum.
- trimSortPrefix() : array<string|int, mixed>|mixed
- Removes sort prefixes from an array.
- TruncateString() : string
- unlink() : bool
- Unlink (Delete) a file.
- zip() : array<string|int, mixed>|bool
- zips an array of files and returns a file array for download
Methods
abbreviateString()
Removes vowels from the string always keeping the first and last letter.
public
static abbreviateString( $str) : bool|string
Parameters
Return values
bool|string —addKeyPrefix()
Adds prefix to all array keys, mainly for reportings and joining array data together to avoid conflicting keys.
public
static addKeyPrefix( $prefix, $arr[, null $ignore_elements = null ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —addSortPrefix()
Adds sort prefixes to an array maintaining the original order. Primarily used because Flex likes to reorded arrays with string keys.
public
static addSortPrefix( $arr[, int $begin_counter = 1 ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —AdjustXY()
public
static AdjustXY( $coord, $adjust_coord) : mixed
Parameters
Return values
mixed —APIFileDownload()
This function helps sending binary data to the client for saving/viewing as a file.
public
static APIFileDownload( $file_name, $type, $data) : bool
Parameters
Tags
Return values
bool —Array2CSV()
public
static Array2CSV( $data[, null $columns = null ][, bool $ignore_last_row = true ][, bool $include_header = true ][, string $eol = "
" ]) : bool|null|string
Parameters
- $data :
- $columns : null = null
- $ignore_last_row : bool = true
- $include_header : bool = true
- $eol : string = " "
Return values
bool|null|string —Array2JSON()
public
static Array2JSON( $data[, null $columns = null ]) : bool|null|string
Parameters
Return values
bool|null|string —Array2XML()
public
static Array2XML( $data[, null $columns = null ][, null $column_format = null ][, bool $ignore_last_row = true ][, bool $include_xml_header = false ][, string $root_element_name = 'data' ][, string $row_element_name = 'row' ]) : bool|null|string
Parameters
- $data :
- $columns : null = null
- $column_format : null = null
- $ignore_last_row : bool = true
- $include_xml_header : bool = false
- $root_element_name : string = 'data'
- $row_element_name : string = 'row'
Return values
bool|null|string —ArrayAssocSum()
This function totals arrays where the data wanting to be totaled is deep in a multi-dimentional array.
public
static ArrayAssocSum( $array[, null $element = null ][, null $decimals = null ][, bool $include_non_numeric = false ]) : array<string|int, mixed>|bool
Usually a row array just before its passed to smarty.
Parameters
Return values
array<string|int, mixed>|bool —ArrayAvg()
public
static ArrayAvg( $arr) : bool|float|int
Parameters
Return values
bool|float|int —arrayChangeValueCase()
Change the case of all values in an array
public
static arrayChangeValueCase( $input[, int $case = CASE_LOWER ]) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —arrayColumn()
public
static arrayColumn([null $input = null ][, null $columnKey = null ][, null $indexKey = null ]) : array<string|int, mixed>|bool|null
Parameters
- $input : null = null
- $columnKey : null = null
- $indexKey : null = null
Return values
array<string|int, mixed>|bool|null —arrayCommonValue()
public
static arrayCommonValue( $arr) : mixed
Parameters
Return values
mixed —arrayCommonValuesForEachKey()
Returns the most common values for each key (column) in the rows.
public
static arrayCommonValuesForEachKey( $rows[, null $filter_columns = null ]) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —arrayDiffAssocRecursive()
public
static arrayDiffAssocRecursive( $array1, $array2) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —arrayDiffByKey()
public
static arrayDiffByKey( $keys, $options) : array<string|int, mixed>|null
Parameters
Return values
array<string|int, mixed>|null —ArrayGroupBy()
This function is similar to a SQL group by clause, only its done on a AssocArray Pass it a row array just before you send it to smarty.
public
static ArrayGroupBy( $array, $group_by_elements[, array<string|int, mixed> $ignore_elements = [] ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —arrayIntersectByKey()
public
static arrayIntersectByKey( $keys, $options) : array<string|int, mixed>|null
Parameters
Return values
array<string|int, mixed>|null —arrayIntersectByRow()
public
static arrayIntersectByRow( $rows) : bool|mixed
Parameters
Return values
bool|mixed —arrayIUnique()
Case insensitive array_unique().
public
static arrayIUnique( $array) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —arrayMergeRecursive()
Merges arrays with overwriting whereas PHP standard array_merge_recursive does not overwrites but combines.
public
static arrayMergeRecursive(array<string|int, mixed> $array1, array<string|int, mixed> $array2) : array<string|int, mixed>
Parameters
- $array1 : array<string|int, mixed>
- $array2 : array<string|int, mixed>
Return values
array<string|int, mixed> —arrayMergeRecursiveDistinct()
This only merges arrays where the array keys must already exist.
public
static arrayMergeRecursiveDistinct(array<string|int, mixed> $array1, array<string|int, mixed> $array2) : array<string|int, mixed>
Parameters
- $array1 : array<string|int, mixed>
- $array2 : array<string|int, mixed>
Return values
array<string|int, mixed> —calculateIncludeExcludeAmount()
public
static calculateIncludeExcludeAmount( $amount, $element[, array<string|int, mixed> $include_elements = [] ][, array<string|int, mixed> $exclude_elements = [] ]) : int
Parameters
- $amount :
- $element :
- $include_elements : array<string|int, mixed> = []
- $exclude_elements : array<string|int, mixed> = []
Return values
int —calculateMultipleColumns()
public
static calculateMultipleColumns( $data[, array<string|int, mixed> $include_elements = [] ][, array<string|int, mixed> $exclude_elements = [] ]) : bool|int|string
Parameters
- $data :
- $include_elements : array<string|int, mixed> = []
- $exclude_elements : array<string|int, mixed> = []
Return values
bool|int|string —calculatePercent()
public
static calculatePercent( $current, $maximum, int $precision) : float|int
Parameters
Return values
float|int —censorString()
censor part of a string for purposes of displaying things like SIN, bank accounts, credit card numbers.
public
static censorString( $str[, string $censor_char = '*' ][, int|null $min_first_chunk_size = null ][, int|null $max_first_chunk_size = null ][, int|null $min_last_chunk_size = null ][, int|null $max_last_chunk_size = null ]) : bool|string
Parameters
- $str :
- $censor_char : string = '*'
- $min_first_chunk_size : int|null = null
- $max_first_chunk_size : int|null = null
- $min_last_chunk_size : int|null = null
- $max_last_chunk_size : int|null = null
Return values
bool|string —checkValidDomain()
Checks if the domain the user is seeing in their browser matches the configured domain that should be used.
public
static checkValidDomain() : bool
If not we can then do a redirect.
Return values
bool —checkValidImage()
public
static checkValidImage( $file_data) : bool
Parameters
Return values
bool —cleanDir()
Delete all files in directory
public
static cleanDir( $path[, $recursive = false ][, bool $del_dirs = false ][, bool $del_root = false ][, $exclude_regex_filter = null ]) : bool
Parameters
- $path :
-
string directory to clean
- $recursive : = false
-
boolean delete files in subdirs
- $del_dirs : bool = false
- $del_root : bool = false
- $exclude_regex_filter : = null
-
string regex to exclude paths
Tags
Return values
bool —compareFloat()
Compares two float values for equality and greater/less than. Required because floats should never be compared directly due to epsilon differences For example: (float)845.92 + (float)14.3 != (float)860.22 -- Yet it does as far as a human is concerned.
public
static compareFloat( $float1, $float2[, string $operator = '==' ]) : bool
Parameters
Return values
bool —convertExcelToCSV()
Converts the first sheet in an Excel file to CSV.
public
static convertExcelToCSV( $xls_file) : bool
Parameters
Return values
bool —convertObjectToArray()
public
static convertObjectToArray(object|array<string|int, mixed> $obj) : array<string|int, mixed>
Parameters
- $obj : object|array<string|int, mixed>
Return values
array<string|int, mixed> —countLinesInFile()
public
static countLinesInFile( $file[, bool $skip_blank_lines = true ]) : int
Parameters
Return values
int —decodeInteger()
public
static decodeInteger( $str[, int $max = 2147483646 ]) : int
Parameters
Return values
int —decrypt()
We can't reliably test that decryption was successful, so type checking should be done in the calling function. (see RemittanceDestinationAccountFactory::getValue3())
public
static decrypt( $str[, null $salt = null ][, null $key = null ]) : bool|string
Parameters
Return values
bool|string —deleteEmptyChildDirectory()
Deletes all empty directories in $path and underneath (down) from it.
public
static deleteEmptyChildDirectory( $path) : bool
Parameters
Return values
bool —deleteEmptyParentDirectory()
Checks to see if the directory $path and $recurse_parent_levels number of parent paths are empty, and deletes them all going *UP* the tree. This will not go *DOWN* the tree.
public
static deleteEmptyParentDirectory( $path, int $recurse_parent_levels) : bool
Parameters
Return values
bool —detectFileDelimiter()
Detects the delimiter of a CSV file (can be semicolon, comma or pipe) by trying every delimiter, then counting how many potential columns could be found with this delimiter and removing the delimiter from array of only one columns could be created (without a working limiter you'll always have "one" column: the entire row).
public
static detectFileDelimiter(string $file) : string|null
The delimiter that created the most columns is returned.
Parameters
- $file : string
-
path to the CSV file
Tags
Return values
string|null —nullable delimiter
detectMobileBrowser()
public
static detectMobileBrowser([null $useragent = null ][, mixed $return_platform = false ]) : bool|string
Parameters
- $useragent : null = null
- $return_platform : mixed = false
Return values
bool|string —disableCaching()
public
static disableCaching([bool $email_notification = true ]) : bool
Parameters
- $email_notification : bool = true
Return values
bool —doesRequestExceedPHPMaxPostSize()
public
static doesRequestExceedPHPMaxPostSize() : bool
Return values
bool —downloadHTTPFile()
public
static downloadHTTPFile( $url, $file_name[, $timeout = 7200 ]) : bool|int
Parameters
Return values
bool|int —encodeInteger()
Encode integer to a alphanumeric value that is reversible.
public
static encodeInteger( $int) : string
Parameters
Return values
string —encrypt()
public
static encrypt( $str[, null $salt = null ][, null $key = null ]) : bool|string
Parameters
Return values
bool|string —escapeCSVTriggerChars()
Mititage CSV Injection attacks: See below links for more information: [1] https://www.owasp.org/index.php/CSV_Excel_Macro_Injection [2] https://hackerone.com/reports/72785 [3] https://hackerone.com/reports/90131
public
static escapeCSVTriggerChars( $input) : mixed
Parameters
Return values
mixed —escapeHTML()
Sanitizes a string or array of strings against XSS attacks. Used before passing data to HTML emails or back to the user in HTML.
public
static escapeHTML(string|array<string|int, mixed> $string) : array<string|int, mixed>|string
Parameters
- $string : string|array<string|int, mixed>
Return values
array<string|int, mixed>|string —Export2XML()
public
static Export2XML( $factory_arr, $filter_data, $output_file) : mixed
Parameters
Return values
mixed —FileDownloadHeader()
public
static FileDownloadHeader( $file_name, $type, $size) : bool
Parameters
Return values
bool —findClosestMatch()
Accepts a search_str and key=>val array that it searches through, to return the array key of the closest fuzzy match.
public
static findClosestMatch( $search_str, $search_arr, int $minimum_percent_match[, bool $return_all_matches = false ]) : array<string|int, mixed>|bool|mixed
Parameters
Return values
array<string|int, mixed>|bool|mixed —findSubmitButton()
public
static findSubmitButton([string $prefix = 'action' ]) : null|string
Parameters
- $prefix : string = 'action'
Return values
null|string —findWebServerOSUser()
public
static findWebServerOSUser() : bool
Return values
bool —flattenArray()
public
static flattenArray( $array[, bool $preserve = false ][, array<string|int, mixed> $r = [] ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —flattenArrayOneLevel()
Flattens an array by only a single level, ie: [ 'level1' => [ 0 => [ 'key' => 'val' ] ] ] becomes: [ 0 => [ 'key' => 'val' ] ]
public
static flattenArrayOneLevel( $array) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —formatAddress()
public
static formatAddress( $name[, bool $address1 = false ][, bool $address2 = false ][, bool $city = false ][, bool $province = false ][, bool $postal_code = false ][, bool $country = false ][, string $format = null ]) : string
Parameters
- $name :
- $address1 : bool = false
- $address2 : bool = false
- $city : bool = false
- $province : bool = false
- $postal_code : bool = false
- $country : bool = false
- $format : string = null
Return values
string —formatEmailAddress()
public
static formatEmailAddress( $email, object $user_obj) : string
Parameters
Return values
string —formatPhoneNumber()
public
static formatPhoneNumber(mixed $phone_number, mixed $country[, mixed $prefix_country_code = null ]) : mixed
Parameters
- $phone_number : mixed
- $country : mixed
- $prefix_country_code : mixed = null
Return values
mixed —generateCopyName()
public
static generateCopyName( $name[, bool $strict = false ][, mixed $max_length = 49 ]) : bool|string
Parameters
Return values
bool|string —generateShareName()
public
static generateShareName( $from, $name[, bool $strict = false ]) : bool|string
Parameters
Return values
bool|string —getAfterDecimal()
public
static getAfterDecimal(float|int|string $float[, bool $format_number = true ]) : int
Parameters
- $float : float|int|string
- $format_number : bool = true
Return values
int —getAmountAroundLimit()
Returns an adjusted current amount, and the amount under a limit and over a limit.
public
static getAmountAroundLimit( $current_amount, $ytd_amount, $ytd_amount_limit) : array<string|int, mixed>|array<string|int, int>
Ideal for calculating wages up to a maximum limit and increasing the YTD amount in a loop. For example social security wage limits.
Parameters
- $current_amount :
-
float Current amount
- $ytd_amount :
-
float Running balance leading up to maximum limit
- $ytd_amount_limit :
-
float Overall maximum limit
Return values
array<string|int, mixed>|array<string|int, int> —getAmountDifferenceToLimit()
This is can be used to handle YTD amounts.
public
static getAmountDifferenceToLimit( $amount, $limit) : string
Parameters
Return values
string —getAmountToLimit()
public
static getAmountToLimit( $amount, $limit) : int
Parameters
Return values
int —getArrayNeighbors()
Uses the internal array pointer to get array neighnors.
public
static getArrayNeighbors( $arr, $key[, string $neighbor = 'both' ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —getBeforeDecimal()
public
static getBeforeDecimal(float|int|string $float) : int
Parameters
- $float : float|int|string
Return values
int —getBytesFromSize()
public
static getBytesFromSize( $val) : int|string
Parameters
Return values
int|string —getCityAndProvinceAndPostalCode()
public
static getCityAndProvinceAndPostalCode( $city, $province, $postal_code) : string
Parameters
Return values
string —getCurrentCompanyProductEdition()
public
static getCurrentCompanyProductEdition() : int
Return values
int —getCurrentOSUser()
public
static getCurrentOSUser() : bool
Return values
bool —getEmailDomain()
public
static getEmailDomain() : string
Return values
string —getEmailLocalPart()
public
static getEmailLocalPart() : string
Return values
string —getEmailReturnPathLocalPart()
public
static getEmailReturnPathLocalPart([null $email = null ]) : string
Parameters
- $email : null = null
Return values
string —getEnvironmentVariableConfigFile()
Generate a shell command to pass thru the TT_CONFIG_FILE environment variable through to executed cron jobs or system job queue commands.
public
static getEnvironmentVariableConfigFile() : string
Return values
string —getFeatureFlag()
Returns the value of a specific feature flag, and if none is set returns the default value.
public
static getFeatureFlag([ $flag = null ][, $default_value = null ]) : mixed|null
Parameters
Return values
mixed|null —getFileList()
public
static getFileList( $start_dir[, null $regex_filter = null ][, bool $recurse = false ]) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —getFullName()
public
static getFullName( $first_name, $middle_name, $last_name[, bool $reverse = false ][, bool $include_middle = true ]) : bool|string
Parameters
Return values
bool|string —getHostName()
public
static getHostName([bool $include_port = true ]) : string
Parameters
- $include_port : bool = true
Return values
string —getHostNameWithoutSubDomain()
public
static getHostNameWithoutSubDomain( $host_name) : string
Parameters
Return values
string —getInstanceIdentificationString()
public
static getInstanceIdentificationString( $primary_company, $system_settings) : string
Parameters
Return values
string —getJSArray()
public
static getJSArray( $values[, null $name = null ][, bool $assoc = false ][, bool $object = false ]) : string
Parameters
Return values
string —getMapURL()
public
static getMapURL( $address1, $address2, $city, $province, $postal_code, $country[, string $service = 'google' ]) : bool|string
Parameters
Return values
bool|string —getMaxSystemLoad()
public
static getMaxSystemLoad() : mixed
Return values
mixed —getMimeType()
public
static getMimeType( $file_name[, bool $buffer = false ][, bool $keep_charset = false ][, string $unknown_type = 'application/octet-stream' ]) : bool|mixed|string
Parameters
- $file_name :
- $buffer : bool = false
- $keep_charset : bool = false
- $unknown_type : string = 'application/octet-stream'
Return values
bool|mixed|string —getMobileAppClientVersion()
public
static getMobileAppClientVersion() : false|mixed|string
Return values
false|mixed|string —getPHPMaxUploadSize()
Checks the max post size and file upload size, and returns the lower of the two.
public
static getPHPMaxUploadSize() : int
Return values
int —getPointerFromArray()
public
static getPointerFromArray( $array, $element[, int $start = 1 ]) : mixed
Parameters
Return values
mixed —getRemoteHTTPFileSize()
public
static getRemoteHTTPFileSize( $url) : bool|mixed
Parameters
Return values
bool|mixed —getRemoteIPAddress()
public
static getRemoteIPAddress() : bool
Return values
bool —getSortDirectionArray()
public
static getSortDirectionArray([bool $text_keys = false ]) : array<string|int, mixed>
Parameters
- $text_keys : bool = false
Return values
array<string|int, mixed> —getSystemLoad()
public
static getSystemLoad() : int|mixed
Return values
int|mixed —getSystemMemoryInfo()
public
static getSystemMemoryInfo() : int|string
Return values
int|string —getUniqueID()
public
static getUniqueID() : string
Return values
string —getURLProtocol()
public
static getURLProtocol() : string
Return values
string —hex2rgb()
public
static hex2rgb( $hex[, bool $asString = true ]) : array<string|int, mixed>|string
Parameters
Return values
array<string|int, mixed>|string —HumanBoolean()
public
static HumanBoolean( $bool) : string
Parameters
Return values
string —importApplyColumnMap()
public
static importApplyColumnMap( $column_map, $csv_arr) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —inArrayByKeyAndValue()
public
static inArrayByKeyAndValue( $arr, $search_key, $search_value) : bool
Parameters
Return values
bool —isCurrentOSUserRoot()
public
static isCurrentOSUserRoot() : bool
Return values
bool —isEmail()
public
static isEmail( $email[, bool $check_dns = true ][, bool $error_level = true ][, bool $return_raw_result = false ][, mixed $enable_smtp_verification = false ]) : bool
Parameters
- $email :
- $check_dns : bool = true
- $error_level : bool = true
- $return_raw_result : bool = false
- $enable_smtp_verification : mixed = false
Tags
Return values
bool —isJSON()
public
static isJSON( $data) : bool
Parameters
Return values
bool —isMobileAppUserAgent()
public
static isMobileAppUserAgent() : bool
Return values
bool —isOpenPort()
public
static isOpenPort( $address[, int $port = 80 ][, int $timeout = 3 ]) : bool
Parameters
Return values
bool —isPortOpen()
public
static isPortOpen(mixed $host, mixed $port[, mixed $timeout = 3 ]) : mixed
Parameters
- $host : mixed
- $port : mixed
- $timeout : mixed = 3
Return values
mixed —isSearchEngineBrowser()
public
static isSearchEngineBrowser([null $useragent = null ]) : bool
Parameters
- $useragent : null = null
Return values
bool —issetOr()
public
static issetOr( &$var[, null $default = null ]) : null
Parameters
Return values
null —isSSL()
public
static isSSL([bool $ignore_force_ssl = false ]) : bool
Parameters
- $ignore_force_ssl : bool = false
Return values
bool —isSubDirectory()
public
static isSubDirectory( $child_dir, $parent_dir) : bool
Parameters
Return values
bool —isSystemLoadValid()
public
static isSystemLoadValid([mixed $multiplier = 1 ]) : bool
Parameters
- $multiplier : mixed = 1
Return values
bool —isUnSupportedBrowser()
public
static isUnSupportedBrowser([null $useragent = null ]) : bool
Parameters
- $useragent : null = null
Return values
bool —isWritable()
Checks to see if a file/directory is writable.
public
static isWritable( $path) : bool
Parameters
Return values
bool —MajorVersionCompare()
public
static MajorVersionCompare( $version1, $version2, $operator) : mixed
Parameters
Return values
mixed —MoneyFormat()
Just a number format that looks like currency without currency symbol can maybe be replaced by TTi18n::numberFormat()
public
static MoneyFormat( $value[, bool $pretty = true ]) : string
Parameters
Return values
string —MoneyRound()
Round currency value without formatting it. In most cases where Misc::MoneyFormat( $var, FALSE ) is used, this should be used instead.
public
static MoneyRound(float|int $value[, int $decimals = 2 ][, null|CurrencyFactory $currency_obj = null ]) : float|int
Parameters
- $value : float|int
- $decimals : int = 2
- $currency_obj : null|CurrencyFactory = null
Return values
float|int —MoneyRoundDifference()
public
static MoneyRoundDifference( $value[, int $decimals = 2 ][, null $currency_obj = null ]) : string
Parameters
Return values
string —NumberToLetter()
Converts a number between 0 and 25 to the corresponding letter.
public
static NumberToLetter( $number) : bool|string
Parameters
Return values
bool|string —parseCallerID()
Caller ID numbers can come in in all sorts of forms: 2505551234 12505551234 +12505551234 (250) 555-1234 Parse out just the digits, and use only the last 10 digits.
public
static parseCallerID( $number) : bool|string
Currently this will not support international numbers
Parameters
Return values
bool|string —parseCSV()
public
static parseCSV( $file[, bool $head = false ][, bool $first_column = false ][, string $delim = ',' ][, int $len = 9216 ][, null $max_lines = null ]) : array<string|int, mixed>|bool
Parameters
- $file :
- $head : bool = false
- $first_column : bool = false
- $delim : string = ','
- $len : int = 9216
- $max_lines : null = null
Return values
array<string|int, mixed>|bool —parseDatabaseHostString()
public
static parseDatabaseHostString( $database_host_string) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —parseFeatureFlags()
Returns all parsed feature flags as an array.
public
static parseFeatureFlags() : array<string|int, mixed>
Return values
array<string|int, mixed> —parseMobileAppUserAgent()
public
static parseMobileAppUserAgent([mixed $user_agent = null ]) : false|mixed|string
Parameters
- $user_agent : mixed = null
Return values
false|mixed|string —parseRFC822EmailAddress()
Parses an RFC822 Email Address ( "John Doe" <john.doe@mydomain.com> ) into its separate components.
public
static parseRFC822EmailAddress( $input[, bool $return_just_key = false ]) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —PercentDistribution()
Take an amount and a distribution array of key => value pairs, value being a decimal percent (ie: 0.50 for 50%) return an array with the same keys and resulting distribution between them.
public
static PercentDistribution( $amount, $percent_arr[, string $remainder_operation = 'last' ][, int $precision = 2 ]) : array<string|int, mixed>|bool
Adding any remainder to the last key is the fastest.
Parameters
Return values
array<string|int, mixed>|bool —prependArray()
public
static prependArray( $prepend_arr, $arr) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —preSetArrayValues()
This function is used to quickly preset array key => value pairs so we don't have to have so many isset() checks throughout the code.
public
static preSetArrayValues( $arr, $keys[, null $preset_value = null ]) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —redirectMobileBrowser()
public
static redirectMobileBrowser() : bool
Return values
bool —redirectUnSupportedBrowser()
public
static redirectUnSupportedBrowser() : bool
Return values
bool —removeDecimal()
public
static removeDecimal( $value) : mixed
Parameters
Return values
mixed —removeKeyPrefix()
Removes prefix to all array keys, mainly for reportings and joining array data together to avoid conflicting keys.
public
static removeKeyPrefix( $prefix, $arr[, null $ignore_elements = null ]) : array<string|int, mixed>|bool
Parameters
Return values
array<string|int, mixed>|bool —removeTrailingZeros()
value should be a float and not a string. be sure to run this before TTi18n currency or number formatter due to foreign numeric formatting for decimal being a comma.
public
static removeTrailingZeros( $value[, int $minimum_decimals = 2 ]) : string
Parameters
Return values
string —rename()
Renames a file or directory. If rename fails for some reason, attempt a copy instead as that might work, specifically on windows where if the file is in use.
public
static rename(string $old_name, string $new_name) : bool
Might fix possible "Access is denied. (code: 5)" errors on Windows when using PHP v5.2 (https://bugs.php.net/bug.php?id=43817) On Windows a directory containing a file formerly opened within the same script may also cause access denied errors in some versions of PHP.
Parameters
- $old_name : string
- $new_name : string
Return values
bool —reScaleRange()
public
static reScaleRange( $value[, int $old_min = 1 ][, int $old_max = 5 ][, int $new_min = 1 ][, int $new_max = 10 ]) : float|int
Parameters
Return values
float|int —Retry()
Generic Retry handler with closures.
public
static Retry( $function[, int $retry_max_attempts = 3 ][, int $retry_sleep = 1 ][, bool $continue_on_error = false ]) : mixed
Parameters
- $function :
-
Closure
- $retry_max_attempts : int = 3
- $retry_sleep : int = 1
- $continue_on_error : bool = false
Tags
Return values
mixed —sanitizeFileName()
Sanitize strings to be used in file names by converting spaces to underscore and removing non-alpha numeric characters
public
static sanitizeFileName( $file_name) : mixed|string|array<string|int, string>|null
Parameters
Return values
mixed|string|array<string|int, string>|null —sendSystemMail()
public
static sendSystemMail( $subject, $body[, null $attachments = null ][, bool $force = false ]) : bool
Parameters
Return values
bool —setProcessUID()
public
static setProcessUID( $uid) : bool
Parameters
Return values
bool —stripDirectoryTraversal()
Removes any sort of directory traversal attacks from a file name, ie: '../../myfile.pdf'
public
static stripDirectoryTraversal( $file_name) : mixed|string|array<string|int, string>|null
Parameters
Return values
mixed|string|array<string|int, string>|null —stripHTMLSpecialChars()
Remove any HTML special char (before its encoded) from the string Useful for things like government forms submitted in XML.
public
static stripHTMLSpecialChars( $str) : mixed
Parameters
Return values
mixed —stripPathAndFileNames()
Strips any mention of path and file names from a string to avoid information exposure vulnerabilities.
public
static stripPathAndFileNames( $str) : array<string|int, mixed>|string|array<string|int, string>|null
Parameters
Return values
array<string|int, mixed>|string|array<string|int, string>|null —stripThe()
Removes the word "the" from the beginning of strings and optionally places it at the end.
public
static stripThe( $str[, bool $add_to_end = false ]) : bool|string
Primarily for client/company names like: The XYZ Company -> XYZ Company, The Should often be used to sanitize metaphones.
Parameters
Return values
bool|string —strReplaceOnce()
public
static strReplaceOnce( $str_pattern, $str_replacement, $string) : mixed
Parameters
Return values
mixed —sumMultipleColumns()
Takes an array with columns, and a 2nd array with column names to sum.
public
static sumMultipleColumns( $data, $sum_elements) : bool|int|string
Parameters
Return values
bool|int|string —trimSortPrefix()
Removes sort prefixes from an array.
public
static trimSortPrefix( $value[, bool $trim_arr_value = false ]) : array<string|int, mixed>|mixed
Parameters
Return values
array<string|int, mixed>|mixed —TruncateString()
public
static TruncateString( $str, $length, int $start[, bool $abbreviate = false ]) : string
Parameters
Return values
string —unlink()
Unlink (Delete) a file.
public
static unlink( $file_name) : bool
Parameters
Return values
bool —zip()
zips an array of files and returns a file array for download
public
static zip( $file_array[, bool $zip_file_name = false ][, bool $ignore_single_file = false ]) : array<string|int, mixed>|bool