$max ) { return $max; } return $value; } } if ( ! function_exists( 'pixcloud_min_max' ) ) { /** * Ensure that value is between $min and $max. * * @param int|float $value * @param int|float $min * @param int|float $max * * @return int|float */ function pixcloud_min_max( $value, $min, $max ) { if ( ! is_numeric( $value ) || ! is_numeric( $min ) || ! is_numeric( $max ) ) { return $value; } if ( $value < $min ) { $value = $min; } if ( $value > $max ) { $value = $max; } return $value; } } if ( ! function_exists( 'pixcloud_add' ) ) { /** * Add something to the value. * * @param int|float $value * @param int|float $add * * @return int|float */ function pixcloud_add( $value, $add ) { if ( ! is_numeric( $value ) || ! is_numeric( $add ) ) { return $value; } return $value + $add; } } if ( ! function_exists( 'pixcloud_substract' ) ) { /** * Substract something from the value. * * @param int|float $value * @param int|float $substract * * @return int|float */ function pixcloud_substract( $value, $substract ) { if ( ! is_numeric( $value ) || ! is_numeric( $substract ) ) { return $value; } return $value - $substract; } } if ( ! function_exists( 'pixcloud_multiply' ) ) { /** * Multiply the value. * * @param int|float $value * @param int|float $multiply * * @return int|float */ function pixcloud_multiply( $value, $multiply ) { if ( ! is_numeric( $value ) || ! is_numeric( $multiply ) ) { return $value; } return $value * $multiply; } } if ( ! function_exists( 'pixcloud_divide' ) ) { /** * Divide the value. * * @param int|float $value * @param int|float $divide * * @return int|float */ function pixcloud_divide( $value, $divide ) { if ( ! is_numeric( $value ) || ! is_numeric( $divide ) || empty( $divide ) ) { return $value; } return $value / $divide; } } if ( ! function_exists( 'pixcloud_modulo' ) ) { /** * Divide the value and get the remainder. * * @param int|float $value * @param int|float $divide * * @return int|float */ function pixcloud_modulo( $value, $divide ) { if ( ! is_numeric( $value ) || ! is_numeric( $divide ) || empty( $divide ) ) { return $value; } return $value % $divide; } }