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;
14 use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
17 * Abstract class that contains common code of integer and float node definitions.
19 * @author David Jeanmonod <david.jeanmonod@gmail.com>
21 abstract class NumericNodeDefinition extends ScalarNodeDefinition
27 * Ensures that the value is smaller than the given reference.
33 * @throws \InvalidArgumentException when the constraint is inconsistent
35 public function max($max)
37 if (isset($this->min) && $this->min > $max) {
38 throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s)', $max, $this->min));
46 * Ensures that the value is bigger than the given reference.
52 * @throws \InvalidArgumentException when the constraint is inconsistent
54 public function min($min)
56 if (isset($this->max) && $this->max < $min) {
57 throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s)', $min, $this->max));
67 * @throws InvalidDefinitionException
69 public function cannotBeEmpty()
71 throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');