3 namespace wcf\system\form\builder\field
;
6 * Provides default implementations of `IMaximumFormField` methods.
8 * @author Matthias Schmidt
9 * @copyright 2001-2019 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package WoltLabSuite\Core\System\Form\Builder\Field
14 trait TMaximumFormField
17 * maximum of the field value
23 * Returns the maximum of the values of this field or `null` if no maximum
28 public function getMaximum()
30 return $this->maximum
;
34 * Sets the maximum of the values of this field. If `null` is passed, the
37 * @param null|number $maximum maximum field value
38 * @return static this field
40 * @throws \InvalidArgumentException if the given maximum is no number or otherwise invalid
42 public function maximum($maximum = null)
44 if ($maximum !== null) {
45 if (!\
is_numeric($maximum)) {
46 throw new \
InvalidArgumentException("Given maximum is no int, '" . \
gettype($maximum) . "' given.");
49 if ($this instanceof IMinimumFormField
) {
50 $minimum = $this->getMinimum();
51 if ($minimum !== null && $minimum > $maximum) {
52 throw new \
InvalidArgumentException(
53 "Minimum ({$minimum}) cannot be greater than maximum ({$maximum})."
59 $this->maximum
= $maximum;