Class Helpers
Some helpers used in several personal packages.
Copyright: 2013 Geoffroy Aubry <geoffroy.aubry@free.fr>
License: http://www.gnu.org/licenses/lgpl.html
SuppressWarnings(TooManyMethods): Copyright (c) 2013 Geoffroy Aubry <geoffroy.aubry@free.fr> Licensed under the GNU Lesser General Public License v3 (LGPL version 3).
Located at helpers/src/GAubry/Helpers/Helpers.php
private
|
|
public static
array
|
|
public static
string
|
#
utf8Encode( string $str )
Returns the UTF-8 translation of the specified string, only if not already in UTF-8. |
public static
array
|
#
exec( string $sCmd, string $sOutputPath = '', string $sErrorPath = '', boolean $bAppend = false )
Executes the given shell command and returns an array filled with every line of output from the command. Trailing whitespace, such as \n, is not included in this array. On shell error (exit code <> 0), throws a \RuntimeException with error message.. |
public static
string
|
|
public static
string
|
|
public static
string
|
#
ucwordWithDelimiters( string $sString, array $aDelimiters = array() )
Returns a string with the first character of each word in specified string capitalized, if that character is alphabetic. Additionally, each character that is immediately after one of $aDelimiters will be capitalized too. |
public static
array
|
#
intToMultiple( integer $iValue, boolean $bBinaryPrefix = false )
Returns specified value in the most appropriate unit, with that unit. If $bBinaryPrefix is FALSE then use SI units (i.e. k, M, G, T), else use IED units (i.e. Ki, Mi, Gi, Ti). |
public static
string
|
#
numberFormat( float $fNumber, string $sDecPoint = '.', string $sThousandsSep = ',', integer $iDecimals = null )
Format a number with grouped thousands. It is an extended version of number_format() that allows do not specify $decimals. |
public static
string
|
#
strPutCSV( array $aInput, string $sDelimiter = ',', string $sEnclosure = '"' )
Formats a line passed as a fields array as CSV and return it, without the trailing newline. Inspiration: http://www.php.net/manual/en/function.str-getcsv.php#88773 |
public static
array
|
#
arrayMergeRecursiveDistinct( array $aArray1, array $aArray2 )
array_merge_recursive() does indeed merge arrays, but it converts values with duplicate keys to arrays rather than overwriting the value in the first array with the duplicate value in the second array, as array_merge does. I.e., with array_merge_recursive(), this happens (documented behavior): |
public static
boolean
|
#
isAssociativeArray( array $aArray )
Returns TRUE iff the specified array is associative. If the specified array is empty, then return FALSE. |