1 | <?php |
||
17 | class RulesBuilder { |
||
18 | |||
19 | /** |
||
20 | * Holds the rules under construction. |
||
21 | */ |
||
22 | protected $rules; |
||
23 | |||
24 | /** |
||
25 | * Creates and returns an instance. |
||
26 | * |
||
27 | * @return RulesBuilder |
||
28 | * the new instance |
||
29 | */ |
||
30 | public static function create() { |
||
33 | |||
34 | /** |
||
35 | * Constructor. |
||
36 | */ |
||
37 | public function __construct() { |
||
40 | |||
41 | /** |
||
42 | * Adds a rule to the set. This function takes a variable amount |
||
43 | * of parameters in order to cover the rule parameters. Example for a rule |
||
44 | * without parameter: |
||
45 | * addRule('myField', 'required') |
||
46 | * Example for a rule with two parameters: |
||
47 | * addRule('myField', 'between', 3, 7) |
||
48 | * |
||
49 | * @param string $field |
||
50 | * the field for the rule |
||
51 | * @param string $rule |
||
52 | * the rule to add |
||
53 | * |
||
54 | * @return RulesBuilder |
||
55 | * the instance of the called RulesBuilder in order to chain the rules |
||
56 | * creation |
||
57 | */ |
||
58 | public function addRule($field, $rule) { |
||
70 | |||
71 | /** |
||
72 | * Gets the created rules. |
||
73 | * |
||
74 | * @return array |
||
75 | * the created rules |
||
76 | */ |
||
77 | public function getRules() { |
||
80 | |||
81 | } |
||
82 |