@@ 111-128 (lines=18) @@ | ||
108 | if (! isset($value_to_validate)) { |
|
109 | $result = false; |
|
110 | } |
|
111 | else { |
|
112 | try { |
|
113 | // TODO support optionnal parameters (offest mainly) ? |
|
114 | $result = preg_match($value, $value_to_validate); |
|
115 | } |
|
116 | catch (\Exception $e) { |
|
117 | // The documentation of preg_match() is wrong and preg_last_error() |
|
118 | // is useless as preg_match returns 0 instead of false |
|
119 | // and then throws an exception with PHP 5.6 |
|
120 | throw new \InvalidArgumentException( |
|
121 | "PCRE error ".var_export($e->getMessage(), true). |
|
122 | " while applying the regexp ".var_export($value, true)." to " |
|
123 | .var_export($value_to_validate, true) |
|
124 | ); |
|
125 | } |
|
126 | ||
127 | $result = (bool) $result; |
|
128 | } |
|
129 | } |
|
130 | else { |
|
131 | throw new \InvalidArgumentException( |
@@ 195-212 (lines=18) @@ | ||
192 | elseif (AboveOrEqualRule::operator === $operator) { |
|
193 | $out = $value_to_validate >= $value; |
|
194 | } |
|
195 | elseif (RegexpRule::operator === $operator) { |
|
196 | try { |
|
197 | // TODO support optionnal parameters (offest mainly) ? |
|
198 | $out = preg_match($value, $value_to_validate); |
|
199 | } |
|
200 | catch (\Exception $e) { |
|
201 | // The documentation of preg_match() is wrong and preg_last_error() |
|
202 | // is useless as preg_match returns 0 instead of false |
|
203 | // and then throws an exception with PHP 5.6 |
|
204 | throw new \InvalidArgumentException( |
|
205 | "PCRE error ".var_export($e->getMessage(), true). |
|
206 | " while applying the regexp ".var_export($value, true)." to " |
|
207 | .var_export($value_to_validate, true) |
|
208 | ); |
|
209 | } |
|
210 | ||
211 | $out = (bool) $out; |
|
212 | } |
|
213 | elseif (NotEqualRule::operator === $operator) { |
|
214 | if (null === $value) { |
|
215 | $out = ! is_null($value_to_validate); |