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\EnumNode;
17 * Enum Node Definition.
19 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
21 class EnumNodeDefinition extends ScalarNodeDefinition
28 public function values(array $values)
30 $values = array_unique($values);
33 throw new \InvalidArgumentException('->values() must be called with at least one value.');
36 $this->values = $values;
44 * @return EnumNode The node
46 * @throws \RuntimeException
48 protected function instantiateNode()
50 if (null === $this->values) {
51 throw new \RuntimeException('You must call ->values() on enum nodes.');
54 return new EnumNode($this->name, $this->parent, $this->values);