FacturaScripts

Utils
in package

Utils give us some basic and common methods.

Tags
author

Carlos García Gómez [email protected]

Table of Contents

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

Methods

bin2str()

Convert a variable with binary content to text.

public static bin2str(mixed $val) : string

It does it in base64.

Parameters
$val : mixed
Return values
string

bool2str()

Convert a boolean to text.

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

dateRange()

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

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

fixHtml()

Make corrections in the HTML code

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

floatcmp()

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

public static floatcmp(float $f1, float $f2[, int $precision = 10 ][, bool $round = 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(string|null $str) : int|null
Parameters
$str : string|null
Return values
int|null

isValidUrl()

public static isValidUrl(string $url) : bool
Parameters
$url : string
Return values
bool

noHtml()

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

public static noHtml(string|null $txt) : string|null

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

Parameters
$txt : string|null
Return values
string|null

normalize()

Normalizes a string replacing accented characters to their normalized counterparts.

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

randomString()

Returns a random text string of length $length.

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

str2bin()

Convert a text to binary.

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

It does with base64.

Parameters
$val : string|null
Return values
string|null

str2bool()

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

public static str2bool(string $val) : 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(string|null $text[, int $maxWidth = 500 ]) : string|null
Parameters
$text : string|null
$maxWidth : int = 500
Return values
string|null

Search results