Gocodebox_Banner_Notifier::int_compare( int $a, int $b, string $operator )
Compare two integers using parameters similar to the version_compare function.
Description Description
This allows us to pass in a comparison character via the notification rules and get a true/false result.
Parameters Parameters
- $a
-
(int) (Required) First integer to compare.
- $b
-
(int) (Required) Second integer to compare.
- $operator
-
(string) (Required) Operator to use, e.g. >, <, >=, <=, =, !=.
Return Return
(bool) true or false based on the operator passed in. Returns null for invalid operators.
Source Source
File: libraries/banner-notifications/src/notifications.php
function int_compare( $a, $b, $operator ) {
switch ( $operator ) {
case '>':
$r = (int) $a > (int) $b;
break;
case '<':
$r = (int) $a < (int) $b;
break;
case '>=':
$r = (int) $a >= (int) $b;
break;
case '<=':
$r = (int) $a <= (int) $b;
break;
case '=':
case '==':
$r = (int) $a == (int) $b;
break;
case '!=':
case '<>':
$r = (int) $a != (int) $b;
break;
default:
$r = null;
}
return $r;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.1.0 | Introduced. |