IntegerNode.php 875 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Config\Definition;
  11. use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
  12. /**
  13. * This node represents an integer value in the config tree.
  14. *
  15. * @author Jeanmonod David <david.jeanmonod@gmail.com>
  16. */
  17. class IntegerNode extends NumericNode
  18. {
  19. /**
  20. * {@inheritDoc}
  21. */
  22. protected function validateType($value)
  23. {
  24. if (!is_int($value)) {
  25. $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected int, but got %s.', $this->getPath(), gettype($value)));
  26. $ex->setPath($this->getPath());
  27. throw $ex;
  28. }
  29. }
  30. }