Test Failed
Branch master (264acb)
by Joe
03:30 queued 01:04
created
src/Validator.php 1 patch
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * @author Joe Huss <[email protected]>
14 14
  */
15
-class Validator
16
-{
15
+class Validator {
17 16
 	protected $zip_names = array(
18 17
 		'BR' => array('name' => 'CEP', 'acronym_text' => 'Código de endereçamento postal (Postal Addressing Code)'),
19 18
 		'CA' => array('name' => 'Postal Code', 'acronym_text' => ''),
@@ -285,54 +284,44 @@  discard block
 block discarded – undo
285 284
 		'ZW' => array(), // Zimbabwe, Notes: System is being planned.
286 285
 	);
287 286
 
288
-	public function isValid($countryCode, $postalCode, $ignoreSpaces = false)
289
-	{
287
+	public function isValid($countryCode, $postalCode, $ignoreSpaces = false) {
290 288
 		//$postalCode = str_replace('-', '', $postalCode);
291
-		if (!isset($this->formats[$countryCode]))
292
-		{
289
+		if (!isset($this->formats[$countryCode])) {
293 290
 			throw new ValidationException(sprintf('Invalid country code: "%s"', $countryCode));
294 291
 		}
295 292
 
296
-		foreach ($this->formats[$countryCode] as $format)
297
-		{
293
+		foreach ($this->formats[$countryCode] as $format) {
298 294
 			#echo $postalCode . ' - ' . $this->getFormatPattern($format)."\n";
299
-			if (preg_match($this->getFormatPattern($format, $ignoreSpaces), $postalCode))
300
-			{
295
+			if (preg_match($this->getFormatPattern($format, $ignoreSpaces), $postalCode)) {
301 296
 				return true;
302 297
 			}
303 298
 		}
304 299
 
305
-		if (!count($this->formats[$countryCode]))
306
-		{
300
+		if (!count($this->formats[$countryCode])) {
307 301
 			return true;
308 302
 		}
309 303
 
310 304
 		return false;
311 305
 	}
312 306
 
313
-	public function getFormats($countryCode)
314
-	{
315
-		if (!isset($this->formats[$countryCode]))
316
-		{
307
+	public function getFormats($countryCode) {
308
+		if (!isset($this->formats[$countryCode])) {
317 309
 			throw new ValidationException(sprintf('Invalid country code: "%s"', $countryCode));
318 310
 		}
319 311
 
320 312
 		return $this->formats[$countryCode];
321 313
 	}
322 314
 
323
-	public function hasCountry($countryCode)
324
-	{
315
+	public function hasCountry($countryCode) {
325 316
 		return (isset($this->formats[$countryCode]));
326 317
 	}
327 318
 
328
-	protected function getFormatPattern($format, $ignoreSpaces = false)
329
-	{
319
+	protected function getFormatPattern($format, $ignoreSpaces = false) {
330 320
 		//$format = str_replace('-', '', $format);
331 321
 		$pattern = str_replace('#', '\d', $format);
332 322
 		$pattern = str_replace('@', '[a-zA-Z]', $pattern);
333 323
 
334
-		if ($ignoreSpaces)
335
-		{
324
+		if ($ignoreSpaces) {
336 325
 			$pattern = str_replace(' ', ' ?', $pattern);
337 326
 		}
338 327
 
Please login to merge, or discard this patch.