. * * @link https://www.librenms.org */ namespace LibreNMS\Util; use Illuminate\Support\Str; use LibreNMS\Exceptions\UserFunctionExistException; class UserFuncHelper { public function __construct( public string|int|float $value, public string|int|float|null $value_raw = null, public array $sensor = [], ) { } public function __call(string $name, array $arguments): mixed { throw new UserFunctionExistException("Invalid user function: $name"); } public function dateToDays(): int { return \LibreNMS\Util\Time::dateToDays($this->value_raw); } public function fsParseChannelValue(): float { $channel = Str::afterLast($this->sensor['sensor_index'], '.'); return Number::cast(explode(',', $this->value_raw)[$channel] ?? ''); } }