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
26 * @param array $values
30 public function values(array $values)
32 $values = array_unique($values);
35 throw new \InvalidArgumentException('->values() must be called with at least one value.');
38 $this->values = $values;
46 * @return EnumNode The node
48 * @throws \RuntimeException
50 protected function instantiateNode()
52 if (null === $this->values) {
53 throw new \RuntimeException('You must call ->values() on enum nodes.');
56 return new EnumNode($this->name, $this->parent, $this->values);