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.


Top ↑

Parameters Parameters

$a

(int) (Required) First integer to compare.

$b

(int) (Required) Second integer to compare.

$operator

(string) (Required) Operator to use, e.g. >, <, >=, <=, =, !=.


Top ↑

Return Return

(bool) true or false based on the operator passed in. Returns null for invalid operators.


Top ↑

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;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.