1 | <?php |
||
15 | class RuleSet |
||
16 | { |
||
17 | /** |
||
18 | * @var \ArrayIterator |
||
19 | */ |
||
20 | protected $rules; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $aliases = array(); |
||
26 | |||
27 | /** |
||
28 | * @var RuleAbstract |
||
29 | */ |
||
30 | protected $default; |
||
31 | |||
32 | /** |
||
33 | * @param RuleAbstract $default default rule |
||
34 | */ |
||
35 | 48 | public function __construct(RuleAbstract $default = null) |
|
36 | { |
||
37 | 48 | $this->rules = new \ArrayIterator(array()); |
|
38 | 48 | $this->default = is_null($default) ? new OptionalField() : $default; |
|
39 | 48 | } |
|
40 | |||
41 | /** |
||
42 | * @return RuleAbstract |
||
43 | */ |
||
44 | 6 | public function getDefault() |
|
45 | { |
||
46 | 6 | return $this->default; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return array |
||
51 | */ |
||
52 | 8 | public function getRules() |
|
56 | |||
57 | /** |
||
58 | * @param RuleAbstract $rule |
||
59 | * @return $this |
||
60 | */ |
||
61 | 31 | public function add(RuleAbstract $rule, array $aliases = array()) |
|
68 | |||
69 | /** |
||
70 | * @param string $name |
||
71 | * @param array $aliases |
||
72 | * @return $this |
||
73 | */ |
||
74 | 32 | public function addAliases($name, array $aliases) |
|
82 | |||
83 | /** |
||
84 | * @param string $name |
||
85 | * @return RuleAbstract |
||
86 | * @throws NotFoundException |
||
87 | */ |
||
88 | 12 | public function get($name) |
|
97 | |||
98 | /** |
||
99 | * @param $alias |
||
100 | * @return string |
||
101 | */ |
||
102 | 13 | public function getNameForAlias($alias) |
|
110 | } |
||
111 |