Source
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CConditionFormula {
// possible parsing states
const STATE_AFTER_OPEN_BRACE = 0;
const STATE_AFTER_OPERATOR = 1;
const STATE_AFTER_CLOSE_BRACE = 2;
const STATE_AFTER_CONSTANT = 3;
const STATE_AFTER_NOT_OPERATOR = 4;
/**
* Set to true of the formula is valid.
*
* @var bool
*/
public $isValid;
/**
* Error message if the formula is invalid.
*
* @var string
*/
public $error;
/**
* The parsed formula.
*
* @var string
*/
public $formula;
/**
* Array of unique constants used in the formula.
*
* @var array
*/
public $constants = [];
/**
* Array of supported operators.
*
* @var array
*/
protected $allowedOperators = ['and', 'or'];
/**
* Current position on a parsed element.
*
* @var integer