FacturaScripts

Utils

Utils give us some basic and common methods.

Table of Contents

bin2str() Convert a variable with binary content to text. string
bool2str() Convert a boolean to text. string
dateRange() Returns an array with all dates between $first and $last. array
fixHtml() Make corrections in the HTML code string
floatcmp() Compare two floating point numbers with an accuracy of $precision, returns True if they are equal, False otherwise. bool
intval() Returns the integer value of the variable $ s, or null if it is null. The intval() function of the php returns 0 if it is null. int
noHtml() This function converts: < to &lt; > to &gt; " to &quot; ' to &#39; string
normalize() Normalizes a string replacing accented characters to their normalized counterparts. string
randomString() Returns a random text string of length $length. string
str2bin() Convert a text to binary. null|string
str2bool() PostgreSQL saves the True values as 't', MySQL as 1. bool
trueTextBreak() Breaks text at maximum width, without break words. string

Methods

bin2str()

Convert a variable with binary content to text.

public static bin2str( $val : mixed ) : string

It does it in base64.

Parameters
$val : mixed
Return values
string

bool2str()

Convert a boolean to text.

public static bool2str( $val : bool ) : string
Parameters
$val : bool
Return values
string

dateRange()

Returns an array with all dates between $first and $last.

public static dateRange( $first : string , $last : string [, $step : string = '+1 day' ] [, $format : string = 'd-m-Y' ] ) : array
Parameters
$first : string
$last : string
$step : string = '+1 day'
$format : string = 'd-m-Y'
Return values
array

fixHtml()

Make corrections in the HTML code

public static fixHtml( $txt : string ) : string
Parameters
$txt : string
Return values
string

floatcmp()

Compare two floating point numbers with an accuracy of $precision, returns True if they are equal, False otherwise.

public static floatcmp( $f1 : float , $f2 : float [, $precision : int = 10 ] [, $round : bool = false ] ) : bool
Parameters
$f1 : float
$f2 : float
$precision : int = 10
$round : bool = false
Return values
bool

intval()

Returns the integer value of the variable $ s, or null if it is null. The intval() function of the php returns 0 if it is null.

public static intval( $str : string ) : int
Parameters
$str : string
Return values
int

noHtml()

This function converts: < to &lt; > to &gt; " to &quot; ' to &#39;

public static noHtml( $txt : string ) : string

Do not be tempted to substitute by htmlentities or htmlspecialshars because you will find many unpleasant surprises.

Parameters
$txt : string
Return values
string

normalize()

Normalizes a string replacing accented characters to their normalized counterparts.

public static normalize( $string : string ) : string
Parameters
$string : string
Return values
string

randomString()

Returns a random text string of length $length.

public static randomString( [ $length : int = 10 ] ) : string
Parameters
$length : int = 10
Return values
string

str2bin()

Convert a text to binary.

public static str2bin( $val : string ) : null|string

It does with base64.

Parameters
$val : string
Return values
null|string

str2bool()

PostgreSQL saves the True values as 't', MySQL as 1.

public static str2bool( $val : string ) : bool

This function returns True if the value corresponds to any of the above.

Parameters
$val : string
Return values
bool

trueTextBreak()

Breaks text at maximum width, without break words.

public static trueTextBreak( $text : mixed [, $maxWidth : int = 500 ] ) : string
Parameters
$text : mixed
$maxWidth : int = 500
Return values
string

Search results