diff options
Diffstat (limited to 'ui/include/classes/widgets/fields/CWidgetFieldIntegerBox.php')
-rw-r--r-- | ui/include/classes/widgets/fields/CWidgetFieldIntegerBox.php | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/ui/include/classes/widgets/fields/CWidgetFieldIntegerBox.php b/ui/include/classes/widgets/fields/CWidgetFieldIntegerBox.php index a246dfda320..32c12e43393 100644 --- a/ui/include/classes/widgets/fields/CWidgetFieldIntegerBox.php +++ b/ui/include/classes/widgets/fields/CWidgetFieldIntegerBox.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types = 0); /* ** Zabbix ** Copyright (C) 2001-2022 Zabbix SIA @@ -19,47 +19,33 @@ **/ -/** - * Widget Field for integer values. - */ -class CWidgetFieldIntegerBox extends CWidgetField { +namespace Zabbix\Widgets\Fields; - /** - * Allowed min value - * - * @var int - */ - private $min; +use Zabbix\Widgets\CWidgetField; - /** - * Allowed max value - * - * @var int - */ - private $max; +class CWidgetFieldIntegerBox extends CWidgetField { + + private int $max; /** - * A numeric box widget field. - * - * @param string $name field name in form - * @param string $label label for the field in form - * @param int $min minimal allowed value (this included) - * @param int $max maximal allowed value (this included) + * @param int $min Minimal allowed value. + * @param int $max Maximal allowed value. */ - public function __construct($name, $label, $min = 0, $max = ZBX_MAX_INT32) { + public function __construct(string $name, string $label = null, int $min = 0, int $max = ZBX_MAX_INT32) { parent::__construct($name, $label); - $this->setSaveType(ZBX_WIDGET_FIELD_TYPE_INT32); - $this->min = $min; $this->max = $max; - $this->setExValidationRules(['in' => $this->min.':'.$this->max]); - } - public function getMaxLength() { - return strlen((string) $this->max); + $this + ->setSaveType(ZBX_WIDGET_FIELD_TYPE_INT32) + ->setExValidationRules(['in' => $min.':'.$this->max]); } - public function setValue($value) { + public function setValue($value): self { return parent::setValue((int) $value); } + + public function getMaxLength(): int { + return strlen((string) $this->max); + } } |