1 | <?php |
||
9 | abstract class AbstractFormatValidator |
||
10 | { |
||
11 | /** |
||
12 | * @access protected |
||
13 | * @var string The type of validation being done. eg "string", "number". |
||
14 | */ |
||
15 | protected $type; |
||
16 | |||
17 | /** |
||
18 | * @access protected |
||
19 | * @var mixed The input being validated. |
||
20 | */ |
||
21 | protected $input; |
||
22 | |||
23 | |||
24 | /** |
||
25 | * Construct the validator. |
||
26 | * |
||
27 | * @access public |
||
28 | * |
||
29 | * @param string $type The type of validation being validated. |
||
30 | */ |
||
31 | public function __construct($type) |
||
35 | |||
36 | |||
37 | /** |
||
38 | * Set the input to validate. |
||
39 | * |
||
40 | * @access public |
||
41 | * |
||
42 | * @param mixed $input The input to validate. |
||
43 | * |
||
44 | * @return void |
||
45 | */ |
||
46 | public function setInput($input) |
||
50 | |||
51 | |||
52 | /** |
||
53 | * Check that the input matches the specified format. |
||
54 | * |
||
55 | * @access public |
||
56 | * |
||
57 | * @param string $format The format to validate against. |
||
58 | * |
||
59 | * @return boolean Is the data valid. |
||
60 | * |
||
61 | * @throws \Exception if the method to validate the format couldn't be found. |
||
62 | */ |
||
63 | public function validateFormat($format) |
||
79 | |||
80 | |||
81 | /** |
||
82 | * Get the name of the method and the parameter to pass to it for the specified format. |
||
83 | * |
||
84 | * @access private |
||
85 | * |
||
86 | * @param string $format The format to validate against. |
||
87 | * |
||
88 | * @return array $methodDetails The name and parameter for the format. |
||
89 | */ |
||
90 | private function getFormatMethodDetails($format) |
||
103 | } |
||
104 |