Source
private static function validatePeriod(string $sec_num, string $time_shift, int $mode, array $options): bool {
<?php declare(strict_types = 0);
/*
** 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 for validating history functions.
*/
class CHistFunctionValidator extends CValidator {
/**
* An options array.
*
* Supported options:
* 'parameters' => [] Definition of parameters of known history functions.
* 'usermacros' => false Enable user macros usage in function parameters.
* 'lldmacros' => false Enable low-level discovery macros usage in function parameters.
* 'calculated' => false Validate history function as part of calculated item formula.
* 'aggregating' => false Validate as aggregating history function.
*
* @var array
*/
private $options = [
'parameters' => [],
'usermacros' => false,
'lldmacros' => false,
'calculated' => false,
'aggregating' => false
];
/**
* @param array $options
*/
public function __construct(array $options = []) {
$this->options = $options + $this->options;
}
/**
* Validate history function.
*
* @param array $token A token of CExpressionParserResult::TOKEN_TYPE_HIST_FUNCTION type.
*
* @return bool
*/
public function validate($token) {
$invalid_param_messages = [
_('invalid first parameter in function "%1$s"'),
_('invalid second parameter in function "%1$s"'),
_('invalid third parameter in function "%1$s"'),
_('invalid fourth parameter in function "%1$s"'),
_('invalid fifth parameter in function "%1$s"'),
_('invalid sixth parameter in function "%1$s"'),