src/Evaluator.php
private static function doOperation( $token, $left, $right ) {
		if ( in_array( $token, [ 'in', 'not-in', 'within', 'not-within' ] ) ) {
			if ( !$right instanceof Range ) {
				$right = new Range( $right );
			}
		}
		switch ( $token ) {
			case 'or':
				return $left || $right;
			case 'and':
				return $left && $right;
			case 'is':
				return $left == $right;
			case 'is-not':
				return $left != $right;
			case 'in':
				return $right->isNumberIn( $left );
			case 'not-in':
				return !$right->isNumberIn( $left );
			case 'within':
				return $right->isNumberWithin( $left );
			case 'not-within':
				return !$right->isNumberWithin( $left );
			case 'mod':
				if ( is_int( $left ) ) {
					return (int)fmod( $left, $right );
				}

				return fmod( $left, $right );
			case ',':
				if ( $left instanceof Range ) {
					$range = $left;
				} else {
					$range = new Range( $left );
				}
				$range->add( $right );

				return $range;
			case '..':
				return new Range( $left, $right );
			default:
				throw new Error( "Invalid RPN token" );
		}
	}
private static function doOperation( $token, $left, $right ) {
		if ( in_array( $token, [ 'in', 'not-in', 'within', 'not-within' ] ) ) {
			if ( !$right instanceof Range ) {
				$right = new Range( $right );
			}
		}
		switch ( $token ) {
			case 'or':
				return $left || $right;
			case 'and':
				return $left && $right;
			case 'is':
				return $left == $right;
			case 'is-not':
				return $left != $right;
			case 'in':
				return $right->isNumberIn( $left );
			case 'not-in':
				return !$right->isNumberIn( $left );
			case 'within':
				return $right->isNumberWithin( $left );
			case 'not-within':
				return !$right->isNumberWithin( $left );
			case 'mod':
				if ( is_int( $left ) ) {
					return (int)fmod( $left, $right );
				}

				return fmod( $left, $right );
			case ',':
				if ( $left instanceof Range ) {
					$range = $left;
				} else {
					$range = new Range( $left );
				}
				$range->add( $right );

				return $range;
			case '..':
				return new Range( $left, $right );
			default:
				throw new Error( "Invalid RPN token" );
		}
	}
private static function doOperation ( $ token , $ left , $ right ) { if ( in_array ( $ token , [ 'in' , 'not-in' , 'within' , 'not-within' ] ) ) { if ( ! $ right instanceof Range ) { $ right = new Range ( $ right ) ; } } switch ( $ token ) { case 'or' : return $ left || $ right ; case 'and' : return $ left && $ right ; case 'is' : return $ left == $ right ; case 'is-not' : return $ left != $ right ; case 'in' : return $ right -> isNumberIn ( $ left ) ; case 'not-in' : return ! $ right -> isNumberIn ( $ left ) ; case 'within' : return $ right -> isNumberWithin ( $ left ) ; case 'not-within' : return ! $ right -> isNumberWithin ( $ left ) ; case 'mod' : if ( is_int ( $ left ) ) { return ( int ) fmod ( $ left , $ right ) ; } return fmod ( $ left , $ right ) ; case ',' : if ( $ left instanceof Range ) { $ range = $ left ; } else { $ range = new Range ( $ left ) ; } $ range -> add ( $ right ) ; return $ range ; case '..' : return new Range ( $ left , $ right ) ; default : throw new Error ( "Invalid RPN token" ) ; } }
Do a single operation

@param string $token The token string
@param mixed $left The left operand. If it is an object, its state may be destroyed.
@param mixed $right The right operand
@throws Error
@return mixed The operation result
Do a single operation