Tools
in package
Tools class.
Tags
Table of Contents
Methods
- afilterKeyExists() : array<string|int, mixed>
- Perform a filter for a multidimensional array and return only vaues with specific keys
- applyDefault() : bool|array<string|int, mixed>
- Apply default values to the array, mainly used for arrays which can't have specific default values defined
- array_set() : array<string|int, mixed>
- Set an array item to a given value using "dot" notation or other separator.
- asortByKey() : void
- Perform a sorting a list array by refference using specified key
- atoattr() : string
- KISS function which convert an array to attributes
- atos() : string
- atos = Array TO String
- dec() : string
- Safety decrypt function
- dtFormatToFormat() : bool|string
- Convert 2 strings representing dates from one format to another
- emailify() : string
- Build an email address using name + email
- enc() : string
- Safety encrypt function
- isAjaxCall() : bool
- Just test ajax Aviato Request/Response rule: If page has action parameter, it is come from ajax call
- isEnclosedIn() : bool
- isGdprSet() : mixed
- Return true if gdpr cookie is enabled for specific service
- mysqlTableFromValues() : string
- Return an mysql synthax temporary table based on values
- printa() : string
- As sprinta, with optional dispatch
- printaa() : string
- As sprintaa with optional output dispatch
- redirect() : mixed
- Simple redirect method (shortcut to header('location: [page]'))
- sprinta() : string
- Alias of str_supplant easy to remember sprinta
- sprintaa() : mixed
- Aplay sprinta to a 2 dimensional array
- str_random() : string
- Generate a random string
- str_supplant() : string
- validateDate() : bool
- Short validator for datetime using DateTime native class
Methods
afilterKeyExists()
Perform a filter for a multidimensional array and return only vaues with specific keys
public
static afilterKeyExists([array<string|int, mixed> $array = [] ][, string $key = '' ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed> = []
-
= array to be filtered
- $key : string = ''
-
= the key searching for
Tags
Return values
array<string|int, mixed> —= filtered array
applyDefault()
Apply default values to the array, mainly used for arrays which can't have specific default values defined
public
static applyDefault(mixed $attributes, mixed $defaultAttributes) : bool|array<string|int, mixed>
Parameters
- $attributes : mixed
-
array
- $defaultAttributes : mixed
-
array
Return values
bool|array<string|int, mixed> —with default values
array_set()
Set an array item to a given value using "dot" notation or other separator.
public
static array_set(array<string|int, mixed> &$array, string|int|null $key, mixed $value[, string $separator = '.' ]) : array<string|int, mixed>
If no key is given to the method, the entire array will be replaced.
Parameters
- $array : array<string|int, mixed>
- $key : string|int|null
- $value : mixed
- $separator : string = '.'
Return values
array<string|int, mixed> —extended method of laravel/framework/src/Illuminate/Collections/Arr.php
asortByKey()
Perform a sorting a list array by refference using specified key
public
static asortByKey(array<string|int, mixed> &$array, string $key[, bool $ascending = true ]) : void
Parameters
- $array : array<string|int, mixed>
-
the array to be sorted
- $key : string
-
the key compared for sorting
- $ascending : bool = true
-
true = sort ascending, false = descending
atoattr()
KISS function which convert an array to attributes
public
static atoattr([array<string|int, mixed> $array = [] ][, string $prefix = '' ]) : string
Parameters
- $array : array<string|int, mixed> = []
-
- the array of values
- $prefix : string = ''
-
- the prefix, need on some specific cases like data- or aria-
Return values
string —- the resutled string of attributes+values concatenated by space.
atos()
atos = Array TO String
public
static atos(mixed $array, mixed $pattern[, mixed $config = [] ]) : string
Parameters
- $array : mixed
-
array - the data to be parsed
- $pattern : mixed
-
string - the template
- $config : mixed = []
Tags
Return values
string —formated using a loop trough $array and apply $pattern
dec()
Safety decrypt function
public
static dec(string $q[, string $key = null ]) : string
Parameters
- $q : string
- $key : string = null
Return values
stringdtFormatToFormat()
Convert 2 strings representing dates from one format to another
public
static dtFormatToFormat(string $date, string $format, string $formatResult[, array<string|int, mixed> $separator = ['/', '-', '.'] ]) : bool|string
Parameters
- $date : string
-
= date to be formated
- $format : string
-
= the format of initial date
- $formatResult : string
-
= the format of the result
- $separator : array<string|int, mixed> = ['/', '-', '.']
-
= the permited separators
Return values
bool|string —representing the date in new format or false on error or false on invalid parameters
exampe: Avi\Tools::dtFormatToFormat('2013-09-11', 'y-m-d', 'd/m/y') will return '11/09/2013'
emailify()
Build an email address using name + email
public
static emailify(string $email[, string $name = null ]) : string
Parameters
- $email : string
-
- valid email address
- $name : string = null
-
- optional name
Return values
string —enc()
Safety encrypt function
public
static enc(string $q[, string $key = null ]) : string
Parameters
- $q : string
- $key : string = null
Tags
Return values
stringisAjaxCall()
Just test ajax Aviato Request/Response rule: If page has action parameter, it is come from ajax call
public
static isAjaxCall([mixed $param = 'action' ]) : bool
Parameters
- $param : mixed = 'action'
Return values
boolisEnclosedIn()
public
static isEnclosedIn(string $string[, string $start = '<' ][, string $end = '>' ]) : bool
Parameters
- $string : string
-
to be check
- $start : string = '<'
-
the start limit
- $end : string = '>'
-
the end limit
Return values
bool —if string is enclosed in start ... end
isGdprSet()
Return true if gdpr cookie is enabled for specific service
public
static isGdprSet(mixed $service) : mixed
Parameters
- $service : mixed
-
string Service enabled or disabled on $_COOKIE['gdpr']
Tags
mysqlTableFromValues()
Return an mysql synthax temporary table based on values
public
static mysqlTableFromValues(string $name, array<string|int, mixed> $values) : string
Parameters
- $name : string
-
- the name of the table
- $values : array<string|int, mixed>
-
- the values of the array
Tags
Return values
string —sql
printa()
As sprinta, with optional dispatch
public
static printa(string $pattern, array<string|int, mixed> $array[, bool $returnOnly = false ]) : string
Parameters
- $pattern : string
- $array : array<string|int, mixed>
- $returnOnly : bool = false
-
, (default = false, will echo result)
Return values
stringprintaa()
As sprintaa with optional output dispatch
public
static printaa(string $pattern, array<string|int, mixed> $array[, bool $returnOnly = false ]) : string
Parameters
- $pattern : string
- $array : array<string|int, mixed>
- $returnOnly : bool = false
-
, (optional = false result in output the buffer content)
Return values
stringredirect()
Simple redirect method (shortcut to header('location: [page]'))
public
static redirect([string $page = '' ][, mixed $extension = '' ]) : mixed
Parameters
- $page : string = ''
-
- the page name(url, permalink)
- $extension : mixed = ''
sprinta()
Alias of str_supplant easy to remember sprinta
public
static sprinta(string $pattern, array<string|int, mixed> $array) : string
Parameters
- $pattern : string
- $array : array<string|int, mixed>
Return values
stringsprintaa()
Aplay sprinta to a 2 dimensional array
public
static sprintaa(string $pattern, array<string|int, mixed> $array) : mixed
Parameters
- $pattern : string
- $array : array<string|int, mixed>
str_random()
Generate a random string
public
static str_random([int $length = 20 ][, string $chr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' ]) : string
Parameters
- $length : int = 20
-
- the length of the needed string
- $chr : string = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
-
- the set of characters used for generating the string
Return values
stringstr_supplant()
public
static str_supplant(string $pattern, array<string|int, mixed> $array) : string
Parameters
- $pattern : string
- $array : array<string|int, mixed>
Tags
Return values
string —Return a string produced according to the pattern by replaceing {*} with array member
validateDate()
Short validator for datetime using DateTime native class
public
static validateDate(string $date[, string $format = 'Y-m-d H:i:s' ]) : bool
Parameters
- $date : string
-
- the string to be validated
- $format : string = 'Y-m-d H:i:s'
-
- optional the format of $date
Tags
Return values
bool —- is format valid yes/no