PHP Class JBZoo\Utils\Vars

ファイルを表示 Open project: jbzoo/utils Class Usage Examples

Public Methods

Method 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 method

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

alphaDigets() public static method

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

bool() public static method

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
return boolean

digits() public static method

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

email() public static method

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

float() public static method

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

get() public static method

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
return mixed

int() public static method

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

isEven() public static method

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

isIn() public static method

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
return boolean

isNegative() public static method

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

isOdd() public static method

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

isPositive() public static method

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

limit() public static method

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

max() public static method

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

min() public static method

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

out() public static method

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
return boolean

relativePercent() public static method

Get relative percent
public static relativePercent ( float $normal, float $current ) : string
$normal float
$current float
return string