From 3099ba9005380562375bd512e75b209716a4faa4 Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Mon, 23 Sep 2013 12:05:51 +0200 Subject: [PATCH 1/2] Fix CS. --- test/Validator/PhoneNumberTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Validator/PhoneNumberTest.php b/test/Validator/PhoneNumberTest.php index 4df50dab..ec7adc64 100644 --- a/test/Validator/PhoneNumberTest.php +++ b/test/Validator/PhoneNumberTest.php @@ -3045,10 +3045,10 @@ public function testExampleNumbers() $this->assertTrue($this->validator->isValid($countryCodePrefixed)); // check fully qualified E.123/E.164 international variants - $fullyQualifiedDoubleO = '00'. $parameters['code'] . $value; + $fullyQualifiedDoubleO = '00' . $parameters['code'] . $value; $this->assertTrue($this->validator->isValid($fullyQualifiedDoubleO)); - $fullyQualifiedPlus = '+'. $parameters['code'] . $value; + $fullyQualifiedPlus = '+' . $parameters['code'] . $value; $this->assertTrue($this->validator->isValid($fullyQualifiedPlus)); } } From 416cf51d396e21c0b34f9b3634b3599d591b6e56 Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Mon, 23 Sep 2013 12:12:04 +0200 Subject: [PATCH 2/2] Fix CS. --- src/Validator/PhoneNumber.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Validator/PhoneNumber.php b/src/Validator/PhoneNumber.php index 7b13deb2..980721ba 100644 --- a/src/Validator/PhoneNumber.php +++ b/src/Validator/PhoneNumber.php @@ -212,18 +212,17 @@ public function isValid($value = null, $context = null) $codeLength = strlen($countryPattern['code']); - // Check for existence of E.123/E.164 prefix + /* + * Check for existence of either: + * 1) E.123/E.164 international prefix + * 2) International double-O prefix + * 3) Bare country prefix + */ if (('+' . $countryPattern['code']) == substr($value, 0, $codeLength + 1)) { $valueNoCountry = substr($value, $codeLength + 1); - } - - // Check for existence of international double-O prefix - elseif (('00' . $countryPattern['code']) == substr($value, 0, $codeLength + 2)) { + } elseif (('00' . $countryPattern['code']) == substr($value, 0, $codeLength + 2)) { $valueNoCountry = substr($value, $codeLength + 2); - } - - // Check for existence of bare country prefix - elseif ($countryPattern['code'] == substr($value, 0, $codeLength)) { + } elseif ($countryPattern['code'] == substr($value, 0, $codeLength)) { $valueNoCountry = substr($value, $codeLength); }