1: <?php
2:
3: namespace Symfony\Component\Config\Definition\Builder;
4:
5: use Symfony\Component\Config\Definition\EnumNode;
6: use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
7:
8: 9: 10: 11: 12:
13: class EnumNodeDefinition extends ScalarNodeDefinition
14: {
15: private $values;
16:
17: public function values(array $values)
18: {
19: $values = array_unique($values);
20:
21: if (count($values) <= 1) {
22: throw new \InvalidArgumentException('->values() must be called with at least two distinct values.');
23: }
24:
25: $this->values = $values;
26:
27: return $this;
28: }
29:
30: 31: 32: 33: 34: 35: 36:
37: protected function instantiateNode()
38: {
39: if (null === $this->values) {
40: throw new \RuntimeException('You must call ->values() on enum nodes.');
41: }
42:
43: return new EnumNode($this->name, $this->parent, $this->values);
44: }
45: }
46: