PHP Class JBZoo\Utils\Vars

Afficher le fichier Open project: jbzoo/utils Class Usage Examples

Méthodes publiques

Méthode Description
alpha ( $value ) : mixed Return only alpha chars
alphaDigets ( $value ) : mixed Return only alpha and digits chars
bool ( string $string ) : boolean Converts many english words that equate to true or false to boolean.
digits ( $value ) : mixed Return only digits chars
email ( $email ) : mixed Validate emil
float ( string $value, integer $round = 10 ) : float
get ( array &$var, mixed $default = null ) : mixed Access an array index, retrieving the value stored there if it exists or a default if it does not.
int ( string $value ) : integer Smart convert any string to int
isEven ( integer $number ) : boolean Is the current value even?
isIn ( integer | float $number, integer | float $min, integer | float $max ) : boolean Return true if the number is within the min and max.
isNegative ( integer $number ) : boolean Is the current value negative; less than zero.
isOdd ( integer $number ) : boolean Is the current value odd?
isPositive ( integer $number, boolean $zero = true ) : boolean Is the current value positive; greater than or equal to zero.
limit ( integer $number, integer $min, integer $max ) : integer Limits the number between two bounds.
max ( integer $number, integer $max ) : integer Decrease the number to the maximum if above threshold.
min ( integer $number, integer $min ) : integer Increase the number to the minimum if below threshold.
out ( integer $number, integer $min, integer $max ) : boolean Return true if the number is outside the min and max.
relativePercent ( float $normal, float $current ) : string Get relative percent

Method Details

alpha() public static méthode

Return only alpha chars
Deprecation: See JBZoo\Utils\Filter
public static alpha ( $value ) : mixed
$value
Résultat mixed

alphaDigets() public static méthode

Return only alpha and digits chars
Deprecation: See JBZoo\Utils\Filter
public static alphaDigets ( $value ) : mixed
$value
Résultat mixed

bool() public static méthode

Converts many english words that equate to true or false to boolean.
Deprecation: See JBZoo\Utils\Filter
public static bool ( string $string ) : boolean
$string string The string to convert to boolean
Résultat boolean

digits() public static méthode

Return only digits chars
Deprecation: See JBZoo\Utils\Filter
public static digits ( $value ) : mixed
$value
Résultat mixed

email() public static méthode

Validate emil
Deprecation: See JBZoo\Utils\Email
public static email ( $email ) : mixed
$email
Résultat mixed

float() public static méthode

Deprecation: See JBZoo\Utils\Filter
public static float ( string $value, integer $round = 10 ) : float
$value string
$round integer
Résultat float

get() public static méthode

This function allows you to concisely access an index which may or may not exist without raising a warning.
public static get ( array &$var, mixed $default = null ) : mixed
$var array Array value to access
$default mixed Default value to return if the key is not
Résultat mixed

int() public static méthode

Smart convert any string to int
Deprecation: See JBZoo\Utils\Filter
public static int ( string $value ) : integer
$value string
Résultat integer

isEven() public static méthode

Is the current value even?
public static isEven ( integer $number ) : boolean
$number integer
Résultat boolean

isIn() public static méthode

Return true if the number is within the min and max.
public static isIn ( integer | float $number, integer | float $min, integer | float $max ) : boolean
$number integer | float
$min integer | float
$max integer | float
Résultat boolean

isNegative() public static méthode

Is the current value negative; less than zero.
public static isNegative ( integer $number ) : boolean
$number integer
Résultat boolean

isOdd() public static méthode

Is the current value odd?
public static isOdd ( integer $number ) : boolean
$number integer
Résultat boolean

isPositive() public static méthode

Is the current value positive; greater than or equal to zero.
public static isPositive ( integer $number, boolean $zero = true ) : boolean
$number integer
$zero boolean
Résultat boolean

limit() public static méthode

Limits the number between two bounds.
public static limit ( integer $number, integer $min, integer $max ) : integer
$number integer
$min integer
$max integer
Résultat integer

max() public static méthode

Decrease the number to the maximum if above threshold.
public static max ( integer $number, integer $max ) : integer
$number integer
$max integer
Résultat integer

min() public static méthode

Increase the number to the minimum if below threshold.
public static min ( integer $number, integer $min ) : integer
$number integer
$min integer
Résultat integer

out() public static méthode

Return true if the number is outside the min and max.
public static out ( integer $number, integer $min, integer $max ) : boolean
$number integer
$min integer
$max integer
Résultat boolean

relativePercent() public static méthode

Get relative percent
public static relativePercent ( float $normal, float $current ) : string
$normal float
$current float
Résultat string