4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Config\Definition\Builder;
15 * Abstract class that contains common code of integer and float node definitions.
17 * @author David Jeanmonod <david.jeanmonod@gmail.com>
19 abstract class NumericNodeDefinition extends ScalarNodeDefinition
25 * Ensures that the value is smaller than the given reference.
31 * @throws \InvalidArgumentException when the constraint is inconsistent
33 public function max($max)
35 if (isset($this->min) && $this->min > $max) {
36 throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s)', $max, $this->min));
44 * Ensures that the value is bigger than the given reference.
50 * @throws \InvalidArgumentException when the constraint is inconsistent
52 public function min($min)
54 if (isset($this->max) && $this->max < $min) {
55 throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s)', $min, $this->max));
65 * @deprecated Deprecated since version 2.8, to be removed in 3.0.
67 public function cannotBeEmpty()
69 @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
71 return parent::cannotBeEmpty();