Source
private static function validatePeriod(string $sec_num, string $time_shift, int $mode, array $options): bool {
<?php declare(strict_types = 0);
/*
** Zabbix
** 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 General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/**
* 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"'),